Fix regression on platforms without ZEND_CHECK_STACK_LIMIT set (8.4) (#16285)

The check called an API only available with this def set.
Gate the check behind ifdef and change control flow to better fit it.

Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
This commit is contained in:
Calvin Buckley 2024-10-08 10:22:23 -03:00 committed by GitHub
parent d76ef13757
commit 4643386703
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1036,10 +1036,12 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, HashTable *ht,
static zend_always_inline bool php_serialize_check_stack_limit(void)
{
#ifdef ZEND_CHECK_STACK_LIMIT
return zend_call_stack_overflowed(EG(stack_limit));
#else
return false;
if (UNEXPECTED(zend_call_stack_overflowed(EG(stack_limit)))) {
zend_call_stack_size_error();
return true;
}
#endif
return false;
}
static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_data_t var_hash, bool in_rcn_array, bool is_root) /* {{{ */
@ -1052,7 +1054,6 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
}
if (UNEXPECTED(php_serialize_check_stack_limit())) {
zend_call_stack_size_error();
return;
}