]> 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:39 +0000 (02:28 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 5 Apr 2006 02:28:39 +0000 (02:28 +0000)
ext/standard/var.c

index 47c8a921e1eee3dec848c1f6e21621b566c46676..dff8b472f4ec43763f497b31111a05e3e43a6dd9 100644 (file)
@@ -1031,10 +1031,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--;
+                                               }
                                        }
                                }
                        }