com php-src: Fixed bug55871.phpt in another way, test script should be changed?: ext/standard/string.c

From: Date: Sun, 02 Mar 2014 14:28:36 +0000
Subject: com php-src: Fixed bug55871.phpt in another way, test script should be changed?: ext/standard/string.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77830@lists.php.net to get a copy of this message
Commit: 38b72bd783ba889d72b2135c4936e1bdd936fa9b Author: Xinchen Hui <laruence@gmail.com> Sun, 2 Mar 2014 22:28:36 +0800 Parents: 0f117ef4d9484837220017520b2fbaa36676cda7 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=38b72bd783ba889d72b2135c4936e1bdd936fa9b Log: Fixed bug55871.phpt in another way, test script should be changed? Bugs: https://bugs.php.net/55871 Changed paths: M ext/standard/string.c Diff: diff --git a/ext/standard/string.c b/ext/standard/string.c index f97417f..66e6a4c 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2409,18 +2409,23 @@ PHP_FUNCTION(substr_replace) zval *orig_str; zval dummy; ulong refcount; -//??? int was_ref; - if(Z_TYPE_P(tmp_str) != IS_STRING) { + if (Z_ISREF_P(tmp_str)) { + /* see bug #55871 */ + ZVAL_DUP(&dummy, Z_REFVAL_P(tmp_str)); + convert_to_string(&dummy); + orig_str = &dummy; + } else if (Z_TYPE_P(tmp_str) != IS_STRING) { ZVAL_DUP(&dummy, tmp_str); convert_to_string(&dummy); orig_str = &dummy; } else { orig_str = tmp_str; } -//??? was_ref = Z_ISREF_P(orig_str); -//??? Z_UNSET_ISREF_P(orig_str); + + /* refcount = Z_REFCOUNT_P(orig_str); + */ if (Z_TYPE_P(from) == IS_ARRAY) { if (NULL != (tmp_from = zend_hash_get_current_data_ex(Z_ARRVAL_P(from), &pos_from))) { @@ -2496,21 +2501,27 @@ PHP_FUNCTION(substr_replace) if (NULL != (tmp_repl = zend_hash_get_current_data_ex(Z_ARRVAL_P(repl), &pos_repl))) { zval *repl_str; zval zrepl; - if(Z_TYPE_P(tmp_repl) != IS_STRING) { + + if (Z_ISREF_P(tmp_repl)) { + tmp_repl = Z_REFVAL_P(tmp_repl); + } + + if (Z_TYPE_P(tmp_repl) != IS_STRING) { ZVAL_DUP(&zrepl, tmp_repl); convert_to_string(&zrepl); repl_str = &zrepl; } else { repl_str = tmp_repl; } - - if(Z_REFCOUNT_P(orig_str) != refcount) { + /* + if (Z_REFCOUNT_P(orig_str) != refcount) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument was modified while replacing"); - if(Z_TYPE_P(tmp_repl) != IS_STRING) { + if (Z_TYPE_P(tmp_repl) != IS_STRING) { zval_dtor(repl_str); } break; } + */ result_len += Z_STRLEN_P(repl_str); zend_hash_move_forward_ex(Z_ARRVAL_P(repl), &pos_repl);

« previous php.cvs (#77830) next »