From 464338670352fa2b4aa124c46c6ab6b27bc91e01 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Tue, 8 Oct 2024 10:22:23 -0300 Subject: [PATCH] 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 --- ext/standard/var.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ext/standard/var.c b/ext/standard/var.c index 248bf086c3c..1c2b0eb164a 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -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; }