From 4c68b8ae3af1fe1b24b5056a5fbfc9e568dc41f5 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 10 Sep 2018 14:47:01 +0200 Subject: Minor code simplification --- src/sp_utils.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') 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, } static char* zend_string_to_char(const zend_string* zs) { - // Remove \0 from the middle of a string + // Remove all \0 in a zend_string and replace them with '0' instead. if (ZSTR_LEN(zs) + 1 < ZSTR_LEN(zs)) { sp_log_err("overflow_error", "Overflow tentative detected in zend_string_to_char"); sp_terminate(); } - char* copy = emalloc(ZSTR_LEN(zs) + 1); - copy[ZSTR_LEN(zs)] = 0; + char* copy = ecalloc(ZSTR_LEN(zs) + 1, 1); for (size_t i = 0; i < ZSTR_LEN(zs); i++) { if (ZSTR_VAL(zs)[i] == '\0') { copy[i] = '0'; -- cgit v1.3