com php-src: Fixed segfault in ext/standard/tests/strings/bug49785.phpt: ext/standard/array.c
| From: | Dmitry Stogov | Date: | Sun, 23 Feb 2014 13:53:48 +0000 |
| Subject: | com php-src: Fixed segfault in ext/standard/tests/strings/bug49785.phpt: ext/standard/array.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77991@lists.php.net to get a copy of this message | ||
Commit: 69a93d2fd79b3e4719e0bb95ee75a6d13275ec3e
Author: Xinchen Hui <laruence@gmail.com> Sun, 23 Feb 2014 21:53:48 +0800
Parents: 70baf8f4192c2834326703cc969878b2daf630f4
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=69a93d2fd79b3e4719e0bb95ee75a6d13275ec3e
Log:
Fixed segfault in ext/standard/tests/strings/bug49785.phpt
Bugs:
https://bugs.php.net/49785
Changed paths:
M ext/standard/array.c
Diff:
diff --git a/ext/standard/array.c b/ext/standard/array.c
index f16cc40..ed56b28 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -2255,20 +2255,26 @@ PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive
TSRMLS
thash->nApplyCount--;
}
} else {
- Z_ADDREF_P(src_entry);
+ if (Z_REFCOUNTED_P(src_entry)) {
+ Z_ADDREF_P(src_entry);
+ }
zend_hash_next_index_insert(Z_ARRVAL_P(dest_entry), &src_zval);
}
if (tmp) {
zval_ptr_dtor(tmp);
}
} else {
- Z_ADDREF_P(src_entry);
+ if (Z_REFCOUNTED_P(src_entry)) {
+ Z_ADDREF_P(src_entry);
+ }
zend_hash_update(dest, string_key, src_entry);
}
break;
case HASH_KEY_IS_LONG:
- Z_ADDREF_P(src_entry);
+ if (Z_REFCOUNTED_P(src_entry)) {
+ Z_ADDREF_P(src_entry);
+ }
zend_hash_next_index_insert(dest, src_entry);
break;
}
@@ -4324,11 +4330,11 @@ PHP_FUNCTION(array_map)
zend_hash_internal_pointer_reset_ex(Z_ARRVAL(arrays[i]), &array_pos[i]);
}
- efree(arrays);
/* Short-circuit: if no callback and only one array, just return it. */
if (!ZEND_FCI_INITIALIZED(fci) && n_arrays == 1) {
RETVAL_ZVAL(args[0], 1, 0);
+ efree(arrays);
efree(array_len);
efree(array_pos);
efree(args);
@@ -4403,6 +4409,7 @@ PHP_FUNCTION(array_map)
}
}
+ efree(arrays);
efree(params);
efree(array_len);
efree(array_pos);