summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-09-13 11:50:18 +0200
committerAnatol Belski <ab@php.net>2016-09-13 12:26:23 +0200
commit18b6f6ee016d558aafb9e7653696ada0f7dff280 (patch)
tree7203203949a21ca528e981aa62953e2cada9400d
parent66c42fcf49ef4d38c916439e60e8d71ea39c8969 (diff)
downloadphp-git-18b6f6ee016d558aafb9e7653696ada0f7dff280.tar.gz
pick up the safe alloc pieces from
19866fb76cf4c95d904ebb0e08592cf38303fae9 (cherry picked from commit c403b3029123aefe0919058b100e80c6bc4e1a6d)
-rw-r--r--ext/imap/php_imap.c2
-rw-r--r--ext/standard/string.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/ext/imap/php_imap.c b/ext/imap/php_imap.c
index 5cfc8adf14..566392fbfd 100644
--- a/ext/imap/php_imap.c
+++ b/ext/imap/php_imap.c
@@ -2977,7 +2977,7 @@ PHP_FUNCTION(imap_utf7_encode)
}
/* allocate output buffer */
- out = zend_string_alloc(outlen, 0);
+ out = zend_string_safe_alloc(1, outlen, 0, 0);
/* encode input string */
outp = (unsigned char*)ZSTR_VAL(out);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 11b8c417b4..46dc8e044d 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2544,7 +2544,7 @@ PHP_FUNCTION(substr_replace)
repl_str = Z_STR_P(repl);
}
- result = zend_string_alloc(Z_STRLEN_P(str) - l + ZSTR_LEN(repl_str), 0);
+ result = zend_string_safe_alloc(1, Z_STRLEN_P(str) - l + ZSTR_LEN(repl_str), 0, 0);
memcpy(ZSTR_VAL(result), Z_STRVAL_P(str), f);
if (ZSTR_LEN(repl_str)) {
@@ -2653,14 +2653,14 @@ PHP_FUNCTION(substr_replace)
result_len += ZSTR_LEN(repl_str);
repl_idx++;
- result = zend_string_alloc(result_len, 0);
+ result = zend_string_safe_alloc(1, result_len, 0, 0);
memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f);
memcpy((ZSTR_VAL(result) + f), ZSTR_VAL(repl_str), ZSTR_LEN(repl_str));
memcpy((ZSTR_VAL(result) + f + ZSTR_LEN(repl_str)), ZSTR_VAL(orig_str) + f + l, ZSTR_LEN(orig_str) - f - l);
zend_string_release(repl_str);
} else {
- result = zend_string_alloc(result_len, 0);
+ result = zend_string_safe_alloc(1, result_len, 0, 0);
memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f);
memcpy((ZSTR_VAL(result) + f), ZSTR_VAL(orig_str) + f + l, ZSTR_LEN(orig_str) - f - l);
@@ -2668,7 +2668,7 @@ PHP_FUNCTION(substr_replace)
} else {
result_len += Z_STRLEN_P(repl);
- result = zend_string_alloc(result_len, 0);
+ result = zend_string_safe_alloc(1, result_len, 0, 0);
memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f);
memcpy((ZSTR_VAL(result) + f), Z_STRVAL_P(repl), Z_STRLEN_P(repl));