Skip to content

Commit 3ab18d4

Browse files
authored
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.
1 parent c5ab727 commit 3ab18d4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sapi/phpdbg/phpdbg_cmd.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
371371

372372
/* {{{ */
373373
PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
374-
if (stack && stack->next) {
374+
ZEND_ASSERT(stack != NULL);
375+
376+
if (stack->next) {
375377
phpdbg_param_t *remove = stack->next;
376378

377379
while (remove) {
@@ -422,10 +424,9 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
422424
remove = next;
423425
else break;
424426
}
425-
}
426427

427-
428-
stack->next = NULL;
428+
stack->next = NULL;
429+
}
429430
} /* }}} */
430431

431432
/* {{{ */

0 commit comments

Comments
 (0)