Skip to content

Commit a2c2eee

Browse files
committed
Introduce a new guard recursion type for var_export
1 parent 03288e3 commit a2c2eee

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Diff for: Zend/zend_types.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ struct _zend_ast_ref {
617617
#define ZEND_GUARD_PROPERTY_ISSET (1<<3)
618618
#define ZEND_GUARD_PROPERTY_MASK 15
619619
#define ZEND_GUARD_RECURSION_DEBUG (1<<4)
620-
#define ZEND_GUARD_RECURSION_JSON (1<<5)
620+
#define ZEND_GUARD_RECURSION_EXPORT (1<<5)
621+
#define ZEND_GUARD_RECURSION_JSON (1<<6)
621622

622623
#define ZEND_GUARD_RECURSION_TYPE(t) ZEND_GUARD_RECURSION_ ## t
623624

Diff for: ext/standard/var.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,12 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
564564
* if the result won't be used. (https://github.com/php/php-src/issues/8044) */
565565
zend_object *zobj = Z_OBJ_P(struc);
566566
uint32_t *guard = zend_get_recursion_guard(zobj);
567-
if (ZEND_GUARD_OR_GC_IS_RECURSIVE(guard, DEBUG, zobj)) {
567+
if (ZEND_GUARD_OR_GC_IS_RECURSIVE(guard, EXPORT, zobj)) {
568568
smart_str_appendl(buf, "NULL", 4);
569569
zend_error(E_WARNING, "var_export does not handle circular references");
570570
return;
571571
}
572-
ZEND_GUARD_OR_GC_PROTECT_RECURSION(guard, DEBUG, zobj);
572+
ZEND_GUARD_OR_GC_PROTECT_RECURSION(guard, EXPORT, zobj);
573573
myht = zend_get_properties_for(struc, ZEND_PROP_PURPOSE_VAR_EXPORT);
574574
if (level > 1) {
575575
smart_str_appendc(buf, '\n');
@@ -603,7 +603,7 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
603603
}
604604
zend_release_properties(myht);
605605
}
606-
ZEND_GUARD_OR_GC_UNPROTECT_RECURSION(guard, DEBUG, zobj);
606+
ZEND_GUARD_OR_GC_UNPROTECT_RECURSION(guard, EXPORT, zobj);
607607
if (level > 1 && !is_enum) {
608608
buffer_append_spaces(buf, level - 1);
609609
}

0 commit comments

Comments
 (0)