com php-src: Fixed segfault when input == NULL: phpdb g_cmd.c phpdbg_prompt.c

From: Date: Tue, 15 Apr 2014 15:52:46 +0000
Subject: com php-src: Fixed segfault when input == NULL: phpdb g_cmd.c phpdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-76985@lists.php.net to get a copy of this message
Commit: 0e8637441c10c1a028d9c4619d32bb8ce9cb3ce4 Author: Bob Weinand <bobwei9@hotmail.com> Tue, 15 Apr 2014 15:52:46 +0000 Parents: 9b05f5d1327aff7f828ba21e705f6a1da306059e Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0e8637441c10c1a028d9c4619d32bb8ce9cb3ce4 Log: Fixed segfault when input == NULL Changed paths: M phpdbg_cmd.c M phpdbg_prompt.c Diff: diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index cc597f1..c6818fe 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -516,21 +516,24 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) { /* {{{ */ PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) { phpdbg_param_t *next = calloc(1, sizeof(phpdbg_param_t)); - + if (!next) return; - + *(next) = *(param); + next->next = NULL; + if (stack->top == NULL) { stack->top = next; + next->top = NULL; stack->next = next; } else { stack->top->next = next; next->top = stack->top; stack->top = next; } - + stack->len++; } /* }}} */ diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index 9a9f45b..86fc4d7 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -1023,18 +1023,18 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ char *why = NULL; char *input = NULL; phpdbg_param_t stack; - + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; input = phpdbg_read_input(NULL TSRMLS_CC); - + if (input) { do { yyscan_t scanner; YY_BUFFER_STATE state; phpdbg_init_param(&stack, STACK_PARAM); - + if (yylex_init(&scanner)) { phpdbg_error( "could not initialize scanner"); @@ -1042,7 +1042,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ } state = yy_scan_string(input, scanner); - + if (yyparse(&stack, scanner) <= 0) { switch (ret = phpdbg_stack_execute(&stack, &why TSRMLS_CC)) { case FAILURE: @@ -1053,7 +1053,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */ } } } - + if (why) { free(why); why = NULL; @@ -1099,14 +1099,13 @@ last: out: if (input) { + phpdbg_stack_free(&stack); phpdbg_destroy_input(&input TSRMLS_CC); } if (why) { free(why); } - - phpdbg_stack_free(&stack); if (EG(in_execution)) { phpdbg_restore_frame(TSRMLS_C);

« previous php.cvs (#76985) next »