Description
At ext/standard/var.c:1010 macros ZEND_HASH_FOREACH_KEY_VAL_IND initiates a cycle, in every iteration of which pointer key is provided.
At ext/standard/var.c:1016 there is a check if(!key), which implies, that key pointer is not guaranteed to not be a NULL. However, right before this check, at ext/standard/var.c:1011 we dereference key pointer by calling zend_string_equals_literal(key, MAGIC_MEMBER) without any additional check.
Possible solution
Adjusting a condition may prevent any unexpected behaviors:
if (key && incomplete_class && zend_string_equals_literal(key, MAGIC_MEMBER)) {
incomplete_class = false;
continue;
}
Found by Linux Verification Center (https://portal.linuxtesting.ru/) using SVACE.
Author D. Meliksetyan.
PHP Version
8.3.31 (found with static analysis)
Operating System
N/A
Description
At
ext/standard/var.c:1010macros ZEND_HASH_FOREACH_KEY_VAL_IND initiates a cycle, in every iteration of which pointerkeyis provided.At
ext/standard/var.c:1016there is a checkif(!key), which implies, thatkeypointer is not guaranteed to not be a NULL. However, right before this check, atext/standard/var.c:1011we dereferencekeypointer by callingzend_string_equals_literal(key, MAGIC_MEMBER)without any additional check.Possible solution
Adjusting a condition may prevent any unexpected behaviors:
Found by Linux Verification Center (https://portal.linuxtesting.ru/) using SVACE.
Author D. Meliksetyan.
PHP Version
Operating System
N/A