@@ -39,6 +39,17 @@ struct php_serialize_data {
3939
4040#define COMMON (is_ref ? "&" : "")
4141
42+ static zend_always_inline bool php_serialize_check_stack_limit (void )
43+ {
44+ #ifdef ZEND_CHECK_STACK_LIMIT
45+ if (UNEXPECTED (zend_call_stack_overflowed (EG (stack_limit )))) {
46+ zend_call_stack_size_error ();
47+ return true;
48+ }
49+ #endif
50+ return false;
51+ }
52+
4253static void php_array_element_dump (zval * zv , zend_ulong index , zend_string * key , int level ) /* {{{ */
4354{
4455 if (key == NULL ) { /* numeric key */
@@ -56,6 +67,10 @@ static void php_object_property_dump(zend_property_info *prop_info, zval *zv, ze
5667{
5768 const char * prop_name , * class_name ;
5869
70+ if (UNEXPECTED (php_serialize_check_stack_limit ())) {
71+ return ;
72+ }
73+
5974 if (key == NULL ) { /* numeric key */
6075 php_printf ("%*c[" ZEND_LONG_FMT "]=>\n" , level + 1 , ' ' , index );
6176 } else { /* string key */
@@ -1029,17 +1044,6 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, HashTable *ht,
10291044}
10301045/* }}} */
10311046
1032- static zend_always_inline bool php_serialize_check_stack_limit (void )
1033- {
1034- #ifdef ZEND_CHECK_STACK_LIMIT
1035- if (UNEXPECTED (zend_call_stack_overflowed (EG (stack_limit )))) {
1036- zend_call_stack_size_error ();
1037- return true;
1038- }
1039- #endif
1040- return false;
1041- }
1042-
10431047static void php_var_serialize_intern (smart_str * buf , zval * struc , php_serialize_data_t var_hash , bool in_rcn_array , bool is_root ) /* {{{ */
10441048{
10451049 zend_long var_already ;
0 commit comments