diff options
| author | jvoisin | 2018-09-10 14:47:01 +0200 |
|---|---|---|
| committer | jvoisin | 2018-09-10 14:47:01 +0200 |
| commit | 4c68b8ae3af1fe1b24b5056a5fbfc9e568dc41f5 (patch) | |
| tree | 5959083822103cf107ab794feaa0d8d0a482953e /src/sp_utils.c | |
| parent | 8db459e1ea3abf3b2318f172184e4cf06da2c29d (diff) | |
Minor code simplification
Diffstat (limited to 'src/sp_utils.c')
| -rw-r--r-- | src/sp_utils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index 8a3874c..8401a92 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -130,16 +130,15 @@ int sp_log_request(const zend_string* folder, const zend_string* text_repr, | |||
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | static char* zend_string_to_char(const zend_string* zs) { | 132 | static char* zend_string_to_char(const zend_string* zs) { |
| 133 | // Remove \0 from the middle of a string | 133 | // Remove all \0 in a zend_string and replace them with '0' instead. |
| 134 | 134 | ||
| 135 | if (ZSTR_LEN(zs) + 1 < ZSTR_LEN(zs)) { | 135 | if (ZSTR_LEN(zs) + 1 < ZSTR_LEN(zs)) { |
| 136 | sp_log_err("overflow_error", | 136 | sp_log_err("overflow_error", |
| 137 | "Overflow tentative detected in zend_string_to_char"); | 137 | "Overflow tentative detected in zend_string_to_char"); |
| 138 | sp_terminate(); | 138 | sp_terminate(); |
| 139 | } | 139 | } |
| 140 | char* copy = emalloc(ZSTR_LEN(zs) + 1); | ||
| 141 | 140 | ||
| 142 | copy[ZSTR_LEN(zs)] = 0; | 141 | char* copy = ecalloc(ZSTR_LEN(zs) + 1, 1); |
| 143 | for (size_t i = 0; i < ZSTR_LEN(zs); i++) { | 142 | for (size_t i = 0; i < ZSTR_LEN(zs); i++) { |
| 144 | if (ZSTR_VAL(zs)[i] == '\0') { | 143 | if (ZSTR_VAL(zs)[i] == '\0') { |
| 145 | copy[i] = '0'; | 144 | copy[i] = '0'; |
