Browse Source

Fix further leaks

pull/1453/head
Bob Weinand 11 years ago
parent
commit
d0ad621906
  1. 6
      sapi/phpdbg/phpdbg.c
  2. 4
      sapi/phpdbg/phpdbg_cmd.c
  3. 4
      sapi/phpdbg/phpdbg_list.c
  4. 26
      sapi/phpdbg/phpdbg_prompt.c

6
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 {

4
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);
}

4
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) {

26
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;
} /* }}} */

Loading…
Cancel
Save