From b2b294a2b20dce7c82ca21dcbc7cb5b0e07099c8 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 18 Oct 2024 11:55:28 +0100 Subject: [PATCH] Fixed bug GH-16037 (Assertion failure in ext/date/php_date.c) --- NEWS | 1 + ext/date/php_date.c | 10 +++++----- ext/date/tests/bug-gh16037.phpt | 9 +++++++++ 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 ext/date/tests/bug-gh16037.phpt diff --git a/NEWS b/NEWS index 3904112a6b595..404b3756685d0 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,7 @@ PHP NEWS - Date: . Fixed bug GH-16454 (Unhandled INF in date_sunset() with tiny $utcOffset). (cmb) + . Fixed bug GH-16037 (Assertion failure in ext/date/php_date.c). (Derick) - DOM: . Fixed bug GH-16316 (DOMXPath breaks when not initialized properly). diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 1f49a7f0e0bf4..92ac3c630b04e 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -2307,7 +2307,7 @@ static void add_common_properties(HashTable *myht, zend_object *zobj) common = zend_std_get_properties(zobj); - ZEND_HASH_MAP_FOREACH_STR_KEY_VAL_IND(common, name, prop) { + ZEND_HASH_FOREACH_STR_KEY_VAL_IND(common, name, prop) { if (zend_hash_add(myht, name, prop) != NULL) { Z_TRY_ADDREF_P(prop); } @@ -2840,7 +2840,7 @@ static void restore_custom_datetime_properties(zval *object, HashTable *myht) zend_string *prop_name; zval *prop_val; - ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + ZEND_HASH_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { if (!prop_name || (Z_TYPE_P(prop_val) == IS_REFERENCE) || date_time_is_internal_property(prop_name)) { continue; } @@ -3883,7 +3883,7 @@ static void restore_custom_datetimezone_properties(zval *object, HashTable *myht zend_string *prop_name; zval *prop_val; - ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + ZEND_HASH_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { if (!prop_name || (Z_TYPE_P(prop_val) == IS_REFERENCE) || date_timezone_is_internal_property(prop_name)) { continue; } @@ -4512,7 +4512,7 @@ static void restore_custom_dateinterval_properties(zval *object, HashTable *myht zend_string *prop_name; zval *prop_val; - ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + ZEND_HASH_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { if (!prop_name || (Z_TYPE_P(prop_val) == IS_REFERENCE) || date_interval_is_internal_property(prop_name)) { continue; } @@ -5504,7 +5504,7 @@ static void restore_custom_dateperiod_properties(zval *object, HashTable *myht) zend_string *prop_name; zval *prop_val; - ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { + ZEND_HASH_FOREACH_STR_KEY_VAL(myht, prop_name, prop_val) { if (!prop_name || (Z_TYPE_P(prop_val) == IS_REFERENCE) || date_period_is_internal_property(prop_name)) { continue; } diff --git a/ext/date/tests/bug-gh16037.phpt b/ext/date/tests/bug-gh16037.phpt new file mode 100644 index 0000000000000..834bc653c2fb5 --- /dev/null +++ b/ext/date/tests/bug-gh16037.phpt @@ -0,0 +1,9 @@ +--TEST-- +Test for bug GH-16037: Assertion failure in ext/date/php_date.c +--FILE-- +__unserialize([[]]); +echo gettype($di); +?> +--EXPECT-- +NULL