]> granicus.if.org Git - php/commitdiff
Fixed segfault when input == NULL
authorBob Weinand <bobwei9@hotmail.com>
Tue, 15 Apr 2014 15:52:46 +0000 (15:52 +0000)
committerBob Weinand <bobwei9@hotmail.com>
Tue, 15 Apr 2014 15:52:46 +0000 (15:52 +0000)
phpdbg_cmd.c
phpdbg_prompt.c

index cc597f13eec3a0e47afb58fb7acfad7653c37883..c6818fea3f7c18892c5f1884319e746bf5346574 100644 (file)
@@ -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++;
 } /* }}} */
 
index 9a9f45b8facf445134f0109838eff0c90fbd4f4a..86fc4d718e5399dd6eb40b3318272514e4539f55 100644 (file)
@@ -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);