cvs: php4 /ext/standard var.c

From: Date: Thu, 14 Mar 2002 09:36:13 +0000
Subject: cvs: php4 /ext/standard var.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10098@lists.php.net to get a copy of this message
yohgaki Thu Mar 14 04:36:13 2002 EDT Modified files: /php4/ext/standard var.c Log: Fixed var_dump() crash when there is recursion. # Since I said it's easy to fix :) Index: php4/ext/standard/var.c diff -u php4/ext/standard/var.c:1.131 php4/ext/standard/var.c:1.132 --- php4/ext/standard/var.c:1.131 Thu Feb 28 22:05:50 2002 +++ php4/ext/standard/var.c Thu Mar 14 04:36:13 2002 @@ -60,6 +60,7 @@ void php_var_dump(zval **struc, int level TSRMLS_DC) { HashTable *myht; + zend_object *object = NULL; if (level > 1) { php_printf("%*c", level - 1, ' '); @@ -85,13 +86,31 @@ break; case IS_ARRAY: myht = Z_ARRVAL_PP(struc); + if (++((*struc)->value.ht->nApplyCount) > 1) { + PUTS("*RECURSION*\n"); + (*struc)->value.ht->nApplyCount = 0; + break; + } php_printf("%sarray(%d) {\n", COMMON, zend_hash_num_elements(myht)); goto head_done; case IS_OBJECT: + object = Z_OBJ_PP(struc); + if (++object->properties->nApplyCount > 1) { + PUTS("*RECURSION*\n"); + object->properties->nApplyCount = 0; + return; + } myht = Z_OBJPROP_PP(struc); php_printf("%sobject(%s)(%d) {\n", COMMON, Z_OBJCE_PP(struc)->name, zend_hash_num_elements(myht)); head_done: + myht = Z_ARRVAL_PP(struc); zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_dump, 1, level); + if (Z_TYPE_PP(struc) == IS_ARRAY) { + (*struc)->value.ht->nApplyCount--; + } + else { + object->properties->nApplyCount--; + } if (level > 1) { php_printf("%*c", level-1, ' '); }

« previous php.cvs (#10098) next »