Skip to content

Make var_export/debug_zval_dump check for infinite recursion on the *object* #8046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove recursion check on object **properties**
The previous commit checked for recursion on the object itself.
Normally, different objects shouldn't share hash tables.
  • Loading branch information
TysonAndre committed Aug 28, 2022
commit a9302fc1937eb59f4f5905432bac654e7edd3baf
22 changes: 0 additions & 22 deletions ext/standard/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,6 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
Z_PROTECT_RECURSION_P(struc);

myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_DEBUG);
if (myht) {
if (GC_IS_RECURSIVE(myht)) {
PUTS("*RECURSION*\n");
zend_release_properties(myht);
Z_UNPROTECT_RECURSION_P(struc);
return;
}
GC_PROTECT_RECURSION(myht);
}
class_name = Z_OBJ_HANDLER_P(struc, get_class_name)(Z_OBJ_P(struc));
php_printf("object(%s)#%d (%d) refcount(%u){\n", ZSTR_VAL(class_name), Z_OBJ_HANDLE_P(struc), myht ? zend_array_count(myht) : 0, Z_REFCOUNT_P(struc));
zend_string_release_ex(class_name, 0);
Expand All @@ -381,7 +372,6 @@ PHPAPI void php_debug_zval_dump(zval *struc, int level) /* {{{ */
zval_object_property_dump(prop_info, val, index, key, level);
}
} ZEND_HASH_FOREACH_END();
GC_UNPROTECT_RECURSION(myht);
zend_release_properties(myht);
}
if (level > 1) {
Expand Down Expand Up @@ -575,17 +565,6 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
}
Z_PROTECT_RECURSION_P(struc);
myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_VAR_EXPORT);
if (myht) {
if (GC_IS_RECURSIVE(myht)) {
Z_UNPROTECT_RECURSION_P(struc);
smart_str_appendl(buf, "NULL", 4);
zend_error(E_WARNING, "var_export does not handle circular references");
zend_release_properties(myht);
return;
} else {
GC_TRY_PROTECT_RECURSION(myht);
}
}
if (level > 1) {
smart_str_appendc(buf, '\n');
buffer_append_spaces(buf, level - 1);
Expand Down Expand Up @@ -616,7 +595,6 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
php_object_element_export(val, index, key, level, buf);
} ZEND_HASH_FOREACH_END();
}
GC_TRY_UNPROTECT_RECURSION(myht);
zend_release_properties(myht);
}
Z_UNPROTECT_RECURSION_P(struc);
Expand Down