Fix leaks from bug #70138

This commit is contained in:
Bob Weinand 2015-07-26 18:11:45 +02:00
parent a717acd21a
commit 9e8fec1ef7
3 changed files with 28 additions and 7 deletions

View file

@ -1309,6 +1309,7 @@ int main(int argc, char **argv) /* {{{ */
char *print_opline_func; char *print_opline_func;
zend_bool ext_stmt = 0; zend_bool ext_stmt = 0;
zend_bool use_mm_wrappers = 0; zend_bool use_mm_wrappers = 0;
zend_bool is_exit;
#ifdef ZTS #ifdef ZTS
void ***tsrm_ls; void ***tsrm_ls;
@ -1353,6 +1354,7 @@ phpdbg_main:
oplog_file = NULL; oplog_file = NULL;
oplog_file_len = 0; oplog_file_len = 0;
flags = PHPDBG_DEFAULT_FLAGS; flags = PHPDBG_DEFAULT_FLAGS;
is_exit = 0;
php_optarg = NULL; php_optarg = NULL;
php_optind = 1; php_optind = 1;
opt = 0; opt = 0;
@ -1915,7 +1917,8 @@ phpdbg_out:
/* In case we aborted during script execution, we may not reset CG(unclean_shutdown) */ /* In case we aborted during script execution, we may not reset CG(unclean_shutdown) */
if (!(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) { if (!(PHPDBG_G(flags) & PHPDBG_IS_RUNNING)) {
CG(unclean_shutdown) = PHPDBG_G(unclean_eval); is_exit = !PHPDBG_G(in_execution) && EG(exit_status) != 255;
CG(unclean_shutdown) = is_exit || PHPDBG_G(unclean_eval);
} }
if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) { if ((PHPDBG_G(flags) & (PHPDBG_IS_CLEANING | PHPDBG_IS_RUNNING)) == PHPDBG_IS_CLEANING) {
@ -1959,10 +1962,12 @@ phpdbg_out:
php_request_shutdown(NULL); php_request_shutdown(NULL);
} zend_end_try(); } zend_end_try();
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING) && PHPDBG_G(in_execution)) { if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
if (!quit_immediately && !phpdbg_startup_run) { if (PHPDBG_G(in_execution) || is_exit) {
phpdbg_notice("stop", "type=\"normal\"", "Script ended normally"); if (!quit_immediately && !phpdbg_startup_run) {
cleaning++; phpdbg_notice("stop", "type=\"normal\"", "Script ended normally");
cleaning++;
}
} }
} }
php_output_deactivate(); php_output_deactivate();

View file

@ -691,7 +691,6 @@ PHPDBG_COMMAND(run) /* {{{ */
PHPDBG_G(in_execution) = 0; PHPDBG_G(in_execution) = 0;
if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) { if (!(PHPDBG_G(flags) & PHPDBG_IS_STOPPING)) {
phpdbg_error("stop", "type=\"bailout\"", "Caught exit/error from VM");
restore = 0; restore = 0;
} else { } else {
zend_bailout(); zend_bailout();
@ -710,9 +709,10 @@ PHPDBG_COMMAND(run) /* {{{ */
PHPDBG_G(in_execution) = 1; PHPDBG_G(in_execution) = 1;
} }
phpdbg_clean(1);
PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING;
phpdbg_clean(1);
} else { } else {
phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!");
} }
@ -794,6 +794,7 @@ PHPDBG_COMMAND(ev) /* {{{ */
EG(vm_stack_top) = original_stack->top; EG(vm_stack_top) = original_stack->top;
EG(vm_stack_end) = original_stack->end; EG(vm_stack_end) = original_stack->end;
EG(vm_stack) = original_stack; EG(vm_stack) = original_stack;
EG(exit_status) = 0;
} zend_end_try(); } zend_end_try();
PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL; PHPDBG_G(flags) &= ~PHPDBG_IN_EVAL;

View file

@ -0,0 +1,15 @@
--TEST--
A script with die() must end "normally"
--PHPDBG--
r
q
--EXPECTF--
[Successful compilation of %s]
prompt> [Script ended normally]
prompt>
--FILE--
<?php
(function($argv) {
die();
})($argv);