com php-src: Fixed reference handling in pcre_grep: ext/p cre/php_pcre.c
| From: | Dmitry Stogov | Date: | Sun, 16 Mar 2014 07:40:35 +0000 |
| Subject: | com php-src: Fixed reference handling in pcre_grep: ext/p cre/php_pcre.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77616@lists.php.net to get a copy of this message | ||
Commit: bf5e00f2e61cbfd2f728d61655fe393be4890299
Author: Xinchen Hui <laruence@gmail.com> Sun, 16 Mar 2014 15:40:35 +0800
Parents: 412ca11eda7f15415f1bca0cf72e15f125ce404d
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bf5e00f2e61cbfd2f728d61655fe393be4890299
Log:
Fixed reference handling in pcre_grep
Changed paths:
M ext/pcre/php_pcre.c
Diff:
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 969fce2..3298f52 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -1776,9 +1776,10 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval
*return
/* Go through the input array */
zend_hash_internal_pointer_reset(Z_ARRVAL_P(input));
while ((entry = zend_hash_get_current_data(Z_ARRVAL_P(input))) != NULL) {
- zval subject;
+ zval subject, *ref_entry = NULL;
if (Z_TYPE_P(entry) == IS_REFERENCE) {
+ ref_entry = entry;
entry = Z_REFVAL_P(entry);
}
@@ -1806,7 +1807,12 @@ PHPAPI void php_pcre_grep_impl(pcre_cache_entry *pce, zval *input, zval
*return
/* If the entry fits our requirements */
if ((count > 0 && !invert) || (count == PCRE_ERROR_NOMATCH && invert)) {
- if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
+ if (ref_entry) {
+ Z_ADDREF_P(ref_entry);
+ entry = ref_entry;
+ } else if (Z_REFCOUNTED_P(entry)) {
+ Z_ADDREF_P(entry);
+ }
/* Add to return array */
switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &num_key, 0, NULL))