php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #60082
Patch recursion-detection revision 2011-10-20 05:44 UTC by tony2001@php.net
Patch bug60082.phpt revision 2011-10-18 12:51 UTC by laruence@php.net
Patch bug60082.patch revision 2011-10-18 12:46 UTC by laruence@php.net

Patch recursion-detection for SPL related Bug #60082

Patch version 2011-10-20 05:44 UTC

Return to Bug #60082 | Download this patch
Patch Revisions:

Developer: tony2001@php.net

Index: ext/spl/spl_array.c
===================================================================
--- ext/spl/spl_array.c	(revision 318241)
+++ ext/spl/spl_array.c	(working copy)
@@ -77,6 +77,7 @@
 	php_serialize_data_t   *serialize_data;
 	php_unserialize_data_t *unserialize_data;
 	HashTable              *debug_info;
+	unsigned char		   nApplyCount;
 } spl_array_object;
 
 static inline HashTable *spl_array_get_hash_table(spl_array_object* intern, int check_std_props TSRMLS_DC) { /* {{{ */
@@ -728,8 +729,17 @@
 static HashTable *spl_array_get_properties(zval *object TSRMLS_DC) /* {{{ */
 {
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
+	HashTable *result;
 
-	return spl_array_get_hash_table(intern, 1 TSRMLS_CC);
+	if (intern->nApplyCount > 1) {
+		/* bail out */
+		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Nesting level too deep - recursive dependency?");
+	}
+
+	intern->nApplyCount++;
+	result = spl_array_get_hash_table(intern, 1 TSRMLS_CC);
+	intern->nApplyCount--;
+	return result;
 } /* }}} */
 
 static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 19:02:15 2014 UTC