diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2015-08-04 01:22:04 +0200 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2015-08-04 01:22:04 +0200 |
commit | d0ad621906dcf2137119c85f2cfb5361c245a06f (patch) | |
tree | 3c0b422f5fca325d56905b3f34b1d5009332f401 | |
parent | d8fe645db444e54fcc8b2555c08a5021c17ca2d3 (diff) | |
download | php-git-d0ad621906dcf2137119c85f2cfb5361c245a06f.tar.gz |
Fix further leaks
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 6 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_cmd.c | 4 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 4 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 26 |
4 files changed, 33 insertions, 7 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 89157562c9..3d7f847d23 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -234,6 +234,12 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ PHPDBG_G(oplog) = NULL; } + if (PHPDBG_G(ops)) { + destroy_op_array(PHPDBG_G(ops)); + efree(PHPDBG_G(ops)); + PHPDBG_G(ops) = NULL; + } + if (PHPDBG_G(oplog_list)) { phpdbg_oplog_list *cur = PHPDBG_G(oplog_list); do { diff --git a/sapi/phpdbg/phpdbg_cmd.c b/sapi/phpdbg/phpdbg_cmd.c index 71a27f5dec..a50b340e7d 100644 --- a/sapi/phpdbg/phpdbg_cmd.c +++ b/sapi/phpdbg/phpdbg_cmd.c @@ -396,6 +396,10 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) { case NUMERIC_FUNCTION_PARAM: case STR_PARAM: case OP_PARAM: + case EVAL_PARAM: + case SHELL_PARAM: + case COND_PARAM: + case RUN_PARAM: if (remove->str) { efree(remove->str); } diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index c30b81bc64..f3181c0701 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -312,10 +312,10 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) { dataptr->op_array = *op_array; if (dataptr->op_array.refcount) { - efree(op_array); + ++*dataptr->op_array.refcount; } - return &dataptr->op_array; + return op_array; } void phpdbg_free_file_source(zval *zv) { diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index e2e3250038..2001129ec8 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -384,6 +384,20 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default) / } /* }}} */ +void phpdbg_clean(zend_bool full) /* {{{ */ +{ + /* this is implicitly required */ + if (PHPDBG_G(ops)) { + destroy_op_array(PHPDBG_G(ops)); + efree(PHPDBG_G(ops)); + PHPDBG_G(ops) = NULL; + } + + if (full) { + PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; + } +} /* }}} */ + PHPDBG_COMMAND(exec) /* {{{ */ { zend_stat_t sb; @@ -409,7 +423,7 @@ PHPDBG_COMMAND(exec) /* {{{ */ if (PHPDBG_G(ops)) { phpdbg_notice("exec", "type=\"unsetops\"", "Destroying compiled opcodes"); - zend_hash_clean(&PHPDBG_G(file_sources)); + phpdbg_clean(0); } PHPDBG_G(exec) = res; @@ -423,7 +437,7 @@ PHPDBG_COMMAND(exec) /* {{{ */ phpdbg_notice("exec", "type=\"set\" context=\"%s\"", "Set execution context: %s", PHPDBG_G(exec)); if (PHPDBG_G(in_execution)) { - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; + phpdbg_clean(1); return SUCCESS; } @@ -651,7 +665,7 @@ PHPDBG_COMMAND(run) /* {{{ */ if (PHPDBG_G(in_execution)) { if (phpdbg_ask_user_permission("Do you really want to restart execution?") == SUCCESS) { phpdbg_startup_run++; - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; + phpdbg_clean(1); } return SUCCESS; } @@ -733,7 +747,8 @@ PHPDBG_COMMAND(run) /* {{{ */ } PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; + + phpdbg_clean(1); } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!"); } @@ -1235,9 +1250,10 @@ PHPDBG_COMMAND(clean) /* {{{ */ phpdbg_writeln("clean", "constants=\"%d\"", "Constants %d", zend_hash_num_elements(EG(zend_constants))); phpdbg_writeln("clean", "includes=\"%d\"", "Includes %d", zend_hash_num_elements(&EG(included_files))); + phpdbg_clean(1); + phpdbg_xml("</cleaninfo>"); - PHPDBG_G(flags) |= PHPDBG_IS_CLEANING; return SUCCESS; } /* }}} */ |