com php-src: Fix further leaks: sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_cmd.c sapi/phpdbg/phpdbg_list.c sapi/phpdbg/phpdbg_prompt.c
| From: | Bob Weinand | Date: | Mon, 03 Aug 2015 23:22:04 +0000 |
| Subject: | com php-src: Fix further leaks: sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_cmd.c sapi/phpdbg/phpdbg_list.c sapi/phpdbg/phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-88290@lists.php.net to get a copy of this message | ||
Commit: d0ad621906dcf2137119c85f2cfb5361c245a06f
Author: Bob Weinand <bobwei9@hotmail.com> Tue, 4 Aug 2015 01:22:04 +0200
Parents: d8fe645db444e54fcc8b2555c08a5021c17ca2d3
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d0ad621906dcf2137119c85f2cfb5361c245a06f
Log:
Fix further leaks
Changed paths:
M sapi/phpdbg/phpdbg.c
M sapi/phpdbg/phpdbg_cmd.c
M sapi/phpdbg/phpdbg_list.c
M sapi/phpdbg/phpdbg_prompt.c
Diff:
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 8915756..3d7f847 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 71a27f5..a50b340 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 c30b81b..f3181c0 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 e2e3250..2001129 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;
} /* }}} */