]> granicus.if.org Git - php/commitdiff
Fixed bug #36957 (serialize() does not handle recursion).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 5 Apr 2006 02:28:06 +0000 (02:28 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 5 Apr 2006 02:28:06 +0000 (02:28 +0000)
NEWS
ext/standard/var.c

diff --git a/NEWS b/NEWS
index b89d0b95d47b7bde90dcc8cdd860b45c117ce566..6f23dd21777f3417a89249d11d0050b7c478fa94 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ PHP                                                                        NEWS
 - Removed the E_STRICT deprecation notice from "var". (Ilia)
 - Fixed debug_zval_dump() to support private and protected members. (Dmitry)
 - Fixed SoapFault::getMessage(). (Dmitry)
+- Fixed bug #36957 (serialize() does not handle recursion). (Ilia)
 - Fixed bug #36941 (ArrayIterator does not clone itself). (Marcus)
 - Fixed bug #36898 (__set() leaks in classes extending internal ones). 
   (Tony, Dmitry)
index 7d107f171acb727c7f8652250b825356c652104b..5a8bb152fda657067336b5275e9d6059fa2a93af 100644 (file)
@@ -815,10 +815,18 @@ static void php_var_serialize_intern(smart_str *buf, zval **struc, HashTable *va
                                        if (zend_hash_get_current_data_ex(myht, 
                                                (void **) &data, &pos) != SUCCESS 
                                                || !data 
-                                               || data == struc) {
+                                               || data == struc
+                                               || (Z_TYPE_PP(data) == IS_ARRAY && Z_ARRVAL_PP(data)->nApplyCount > 1)
+                                       ) {
                                                smart_str_appendl(buf, "N;", 2);
                                        } else {
+                                               if (Z_TYPE_PP(data) == IS_ARRAY) {
+                                                       Z_ARRVAL_PP(data)->nApplyCount++;
+                                               }
                                                php_var_serialize_intern(buf, data, var_hash TSRMLS_CC);
+                                               if (Z_TYPE_PP(data) == IS_ARRAY) {
+                                                       Z_ARRVAL_PP(data)->nApplyCount--;
+                                               }
                                        }
                                }
                        }