com php-src: release only appropriate string: ext/standard/string.c
| From: | Anatol Belski | Date: | Tue, 22 Dec 2015 13:33:19 +0000 |
| Subject: | com php-src: release only appropriate string: ext/standard/string.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90385@lists.php.net to get a copy of this message | ||
Commit: 4037ba5847d04d143d5e165e90e1fbc5fe760c59
Author: Anatol Belski <ab@php.net> Tue, 22 Dec 2015 14:33:19 +0100
Parents: a3e37e0818220a450dd2915c31df47a9fa08c6bb
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4037ba5847d04d143d5e165e90e1fbc5fe760c59
Log:
release only appropriate string
Changed paths:
M ext/standard/string.c
Diff:
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 34ef5a6..0e4e48f 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -2496,6 +2496,7 @@ PHP_FUNCTION(substr_replace)
if (Z_TYPE_P(str) != IS_ARRAY) {
if (Z_TYPE_P(from) != IS_ARRAY) {
zend_string *repl_str;
+ zend_bool repl_release = 0;
f = Z_LVAL_P(from);
/* if "from" position is negative, count start position from the end
@@ -2537,6 +2538,7 @@ PHP_FUNCTION(substr_replace)
}
if (repl_idx < Z_ARRVAL_P(repl)->nNumUsed) {
repl_str = zval_get_string(tmp_repl);
+ repl_release = 1;
} else {
repl_str = STR_EMPTY_ALLOC();
}
@@ -2552,7 +2554,9 @@ PHP_FUNCTION(substr_replace)
}
memcpy((ZSTR_VAL(result) + f + ZSTR_LEN(repl_str)), Z_STRVAL_P(str) + f + l, Z_STRLEN_P(str) - f
- l);
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
- zend_string_release(repl_str);
+ if (repl_release) {
+ zend_string_release(repl_str);
+ }
RETURN_NEW_STR(result);
} else {
php_error_docref(NULL, E_WARNING, "Functionality of 'from' and 'len' as
arrays is not implemented");