summaryrefslogtreecommitdiff
path: root/ext/standard/var.c
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-03-14 09:36:13 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-03-14 09:36:13 +0000
commitdcd86d154e5b5eb5e8dfe440dbb85bb90dfb8e7e (patch)
treefdf86c534e86e1a2e282ab1c2f3d341791821bd3 /ext/standard/var.c
parentc62a7c94749531aa0c129a64bda3a6dc5cbd27f9 (diff)
downloadphp-git-dcd86d154e5b5eb5e8dfe440dbb85bb90dfb8e7e.tar.gz
Fixed var_dump() crash when there is recursion.
# Since I said it's easy to fix :)
Diffstat (limited to 'ext/standard/var.c')
-rw-r--r--ext/standard/var.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 65fa4e9431..3604d74b0c 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -60,6 +60,7 @@ static int php_array_element_dump(zval **zv, int num_args, va_list args, zend_ha
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 @@ void php_var_dump(zval **struc, int level TSRMLS_DC)
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, ' ');
}