jani            Wed Aug 20 01:21:48 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/pcre/tests     bug44925.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/pcre   php_pcre.c 
  Log:
  MFH: - Fixed bug #44925 (preg_grep() modifies input array). (Nuno)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1202&r2=1.2027.2.547.2.1203&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1202 php-src/NEWS:1.2027.2.547.2.1203
--- php-src/NEWS:1.2027.2.547.2.1202    Wed Aug 20 00:52:12 2008
+++ php-src/NEWS        Wed Aug 20 01:21:46 2008
@@ -63,6 +63,7 @@
   and hash()). (Tony)
 - Fixed bug #45004 (pg_insert() does not accept 4 digit timezone format).
   (Ilia)
+- Fixed bug #44925 (preg_grep() modifies input array). (Nuno)
 - Fixed bug #44891 Memory leak using registerPHPFunctions and XSLT Variable 
   as function parameter. (Rob)
 - Fixed bug #44830 (Very minor issue with backslash in heredoc). (Matt)
http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/php_pcre.c?r1=1.168.2.9.2.27&r2=1.168.2.9.2.28&diff_format=u
Index: php-src/ext/pcre/php_pcre.c
diff -u php-src/ext/pcre/php_pcre.c:1.168.2.9.2.27 
php-src/ext/pcre/php_pcre.c:1.168.2.9.2.28
--- php-src/ext/pcre/php_pcre.c:1.168.2.9.2.27  Wed Aug 20 00:52:13 2008
+++ php-src/ext/pcre/php_pcre.c Wed Aug 20 01:21:47 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_pcre.c,v 1.168.2.9.2.27 2008/08/20 00:52:13 jani Exp $ */
+/* $Id: php_pcre.c,v 1.168.2.9.2.28 2008/08/20 01:21:47 jani Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1731,13 +1731,17 @@
 
        /* Go through the input array */
        zend_hash_internal_pointer_reset(Z_ARRVAL_P(input));
-       while(zend_hash_get_current_data(Z_ARRVAL_P(input), (void **)&entry) == 
SUCCESS) {
+       while (zend_hash_get_current_data(Z_ARRVAL_P(input), (void **)&entry) 
== SUCCESS) {
+               zval subject = **entry;
 
-               convert_to_string_ex(entry);
+               if (Z_TYPE_PP(entry) != IS_STRING) {
+                       zval_copy_ctor(&subject);
+                       convert_to_string(&subject);
+               }
 
                /* Perform the match */
-               count = pcre_exec(pce->re, extra, Z_STRVAL_PP(entry),
-                                                 Z_STRLEN_PP(entry), 0,
+               count = pcre_exec(pce->re, extra, Z_STRVAL(subject),
+                                                 Z_STRLEN(subject), 0,
                                                  0, offsets, size_offsets);
 
                /* Check for too many substrings condition. */
@@ -1750,9 +1754,8 @@
                }
 
                /* If the entry fits our requirements */
-               if ((count > 0 && !invert) ||
-                       (count == PCRE_ERROR_NOMATCH && invert)) {
-                       (*entry)->refcount++;
+               if ((count > 0 && !invert) || (count == PCRE_ERROR_NOMATCH && 
invert)) {
+                       ZVAL_ADDREF(*entry);
 
                        /* Add to return array */
                        switch (zend_hash_get_current_key(Z_ARRVAL_P(input), 
&string_key, &num_key, 0))
@@ -1768,7 +1771,11 @@
                                        break;
                        }
                }
-               
+
+               if (Z_TYPE_PP(entry) != IS_STRING) {
+                       zval_dtor(&subject);
+               }
+
                zend_hash_move_forward(Z_ARRVAL_P(input));
        }
        zend_hash_internal_pointer_reset(Z_ARRVAL_P(input));

http://cvs.php.net/viewvc.cgi/php-src/ext/pcre/tests/bug44925.phpt?view=markup&rev=1.1
Index: php-src/ext/pcre/tests/bug44925.phpt
+++ php-src/ext/pcre/tests/bug44925.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to