fix memory errors

This commit is contained in:
krakjoe 2013-11-18 21:59:42 +00:00
parent 9b30877d56
commit a582d2793d
5 changed files with 63 additions and 40 deletions

View file

@ -98,20 +98,23 @@ parsed:
void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
{
switch (param->type) {
case FILE_PARAM:
efree(param->file.name);
break;
case METHOD_PARAM:
efree(param->method.class);
efree(param->method.name);
break;
case STR_PARAM:
efree(param->str);
break;
default:
break;
if (param) {
switch (param->type) {
case FILE_PARAM:
efree(param->file.name);
break;
case METHOD_PARAM:
efree(param->method.class);
efree(param->method.name);
break;
case STR_PARAM:
efree(param->str);
break;
default:
break;
}
}
} /* }}} */
int phpdbg_do_cmd( const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{ */
@ -132,19 +135,13 @@ int phpdbg_do_cmd( const phpdbg_command_t *command, char *cmd_line, size_t cmd_l
if ((command->name_len == expr_len && memcmp(cmd, command->name, expr_len) == 0)
|| (expr_len == 1 && command->alias && command->alias == cmd_line[0])) {
phpdbg_param_t lparam,
param;
phpdbg_param_t param = {0};
phpdbg_parse_param(
expr,
(cmd_len - expr_len) ? (((cmd_len - expr_len) - sizeof(" "))+1) : 0,
&param TSRMLS_CC);
lparam = PHPDBG_G(lparam);
PHPDBG_G(lparam) = param;
PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
if (command->subs && param.type == STR_PARAM) {
if (phpdbg_do_cmd(command->subs, param.str, param.len TSRMLS_CC) == SUCCESS) {
rc = SUCCESS;
@ -159,10 +156,12 @@ int phpdbg_do_cmd( const phpdbg_command_t *command, char *cmd_line, size_t cmd_l
phpdbg_error("This command does not expect argument!");
rc = FAILURE;
} else {
rc = command->handler(&param TSRMLS_CC);
rc = command->handler(
&param TSRMLS_CC);
PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
PHPDBG_G(lparam) = param;
}
phpdbg_clear_param(&lparam TSRMLS_CC);
break;
}
++command;