Skip to content

Commit ff4dfc5

Browse files
author
Shane Caraveo
committed
prevent php from crashing when serializing circular data.
This script produced the crash. <? $hash["test_key"] = "test_value"; $hash["hash_key"] = &$hash; echo serialize($hash); ?>
1 parent b5dfb0d commit ff4dfc5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

ext/standard/var.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ PHPAPI void php_var_serialize(zval *buf, zval **struc, HashTable *var_hash)
342342
FREE_ZVAL(d);
343343
break;
344344
}
345+
if (data == struc) return;
345346
php_var_serialize(buf, data, var_hash);
346347
}
347348
}

0 commit comments

Comments
 (0)