1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Change if (stack) check to an assertion (#10090)

The code checks if stack is a NULL pointer. Below that if the
stack->next pointer is updated unconditionally. Therefore a call with a
NULL pointer will crash, even though the if (stack) check seems to show
the intent that it is valid to call the function with NULL.
The function is not meant to be called with NULL, so just ZEND_ASSERT
instead.
This commit is contained in:
Niels
2022-12-13 13:16:52 +01:00
committed by GitHub
parent c5ab72773d
commit 3ab18d4d14

View File

@@ -371,7 +371,9 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
/* {{{ */
PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
if (stack && stack->next) {
ZEND_ASSERT(stack != NULL);
if (stack->next) {
phpdbg_param_t *remove = stack->next;
while (remove) {
@@ -422,10 +424,9 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
remove = next;
else break;
}
stack->next = NULL;
}
stack->next = NULL;
} /* }}} */
/* {{{ */