mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
fix memory errors
This commit is contained in:
parent
9b30877d56
commit
a582d2793d
5 changed files with 63 additions and 40 deletions
5
phpdbg.c
5
phpdbg.c
|
@ -599,6 +599,11 @@ phpdbg_main:
|
||||||
|
|
||||||
/* print blurb */
|
/* print blurb */
|
||||||
phpdbg_welcome((cleaning > 0) TSRMLS_CC);
|
phpdbg_welcome((cleaning > 0) TSRMLS_CC);
|
||||||
|
|
||||||
|
zend_try {
|
||||||
|
/* activate globals, they can be overwritten */
|
||||||
|
zend_activate_auto_globals(TSRMLS_C);
|
||||||
|
} zend_end_try();
|
||||||
|
|
||||||
/* initialize from file */
|
/* initialize from file */
|
||||||
zend_try {
|
zend_try {
|
||||||
|
|
4
phpdbg.h
4
phpdbg.h
|
@ -96,6 +96,8 @@
|
||||||
#define PHPDBG_IN_LEAVE (1<<15)
|
#define PHPDBG_IN_LEAVE (1<<15)
|
||||||
#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL|PHPDBG_IN_FINISH|PHPDBG_IN_LEAVE)
|
#define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL|PHPDBG_IN_FINISH|PHPDBG_IN_LEAVE)
|
||||||
|
|
||||||
|
#define PHPDBG_IS_REGISTERED (1<<16)
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
|
# define PHPDBG_DEFAULT_FLAGS (PHPDBG_IS_QUIET|PHPDBG_IS_COLOURED)
|
||||||
#else
|
#else
|
||||||
|
@ -115,7 +117,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
|
||||||
int bp_count; /* breakpoint count */
|
int bp_count; /* breakpoint count */
|
||||||
int vmret; /* return from last opcode handler execution */
|
int vmret; /* return from last opcode handler execution */
|
||||||
phpdbg_command_t *lcmd; /* last command */
|
phpdbg_command_t *lcmd; /* last command */
|
||||||
phpdbg_param_t lparam; /* last param */
|
phpdbg_param_t lparam; /* last param */
|
||||||
FILE *oplog; /* opline log */
|
FILE *oplog; /* opline log */
|
||||||
HashTable seek; /* seek oplines */
|
HashTable seek; /* seek oplines */
|
||||||
zend_ulong flags; /* phpdbg flags */
|
zend_ulong flags; /* phpdbg flags */
|
||||||
|
|
45
phpdbg_cmd.c
45
phpdbg_cmd.c
|
@ -98,20 +98,23 @@ parsed:
|
||||||
|
|
||||||
void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
|
void phpdbg_clear_param(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
switch (param->type) {
|
if (param) {
|
||||||
case FILE_PARAM:
|
switch (param->type) {
|
||||||
efree(param->file.name);
|
case FILE_PARAM:
|
||||||
break;
|
efree(param->file.name);
|
||||||
case METHOD_PARAM:
|
break;
|
||||||
efree(param->method.class);
|
case METHOD_PARAM:
|
||||||
efree(param->method.name);
|
efree(param->method.class);
|
||||||
break;
|
efree(param->method.name);
|
||||||
case STR_PARAM:
|
break;
|
||||||
efree(param->str);
|
case STR_PARAM:
|
||||||
break;
|
efree(param->str);
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
int phpdbg_do_cmd( const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{ */
|
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)
|
if ((command->name_len == expr_len && memcmp(cmd, command->name, expr_len) == 0)
|
||||||
|| (expr_len == 1 && command->alias && command->alias == cmd_line[0])) {
|
|| (expr_len == 1 && command->alias && command->alias == cmd_line[0])) {
|
||||||
|
|
||||||
phpdbg_param_t lparam,
|
phpdbg_param_t param = {0};
|
||||||
param;
|
|
||||||
|
|
||||||
phpdbg_parse_param(
|
phpdbg_parse_param(
|
||||||
expr,
|
expr,
|
||||||
(cmd_len - expr_len) ? (((cmd_len - expr_len) - sizeof(" "))+1) : 0,
|
(cmd_len - expr_len) ? (((cmd_len - expr_len) - sizeof(" "))+1) : 0,
|
||||||
¶m TSRMLS_CC);
|
¶m 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 (command->subs && param.type == STR_PARAM) {
|
||||||
if (phpdbg_do_cmd(command->subs, param.str, param.len TSRMLS_CC) == SUCCESS) {
|
if (phpdbg_do_cmd(command->subs, param.str, param.len TSRMLS_CC) == SUCCESS) {
|
||||||
rc = 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!");
|
phpdbg_error("This command does not expect argument!");
|
||||||
rc = FAILURE;
|
rc = FAILURE;
|
||||||
} else {
|
} else {
|
||||||
rc = command->handler(¶m TSRMLS_CC);
|
rc = command->handler(
|
||||||
|
¶m TSRMLS_CC);
|
||||||
|
|
||||||
|
PHPDBG_G(lcmd) = (phpdbg_command_t*) command;
|
||||||
|
PHPDBG_G(lparam) = param;
|
||||||
}
|
}
|
||||||
|
|
||||||
phpdbg_clear_param(&lparam TSRMLS_CC);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++command;
|
++command;
|
||||||
|
|
|
@ -52,9 +52,10 @@ PHPDBG_INFO(error) /* {{{ */
|
||||||
|
|
||||||
PHPDBG_INFO(vars) /* {{{ */
|
PHPDBG_INFO(vars) /* {{{ */
|
||||||
{
|
{
|
||||||
|
HashTable vars;
|
||||||
HashPosition pos;
|
HashPosition pos;
|
||||||
char *var;
|
char *var;
|
||||||
zval **data;
|
zval **data, *zdata;
|
||||||
|
|
||||||
if (!EG(active_symbol_table)) {
|
if (!EG(active_symbol_table)) {
|
||||||
zend_rebuild_symbol_table(TSRMLS_C);
|
zend_rebuild_symbol_table(TSRMLS_C);
|
||||||
|
@ -64,25 +65,46 @@ PHPDBG_INFO(vars) /* {{{ */
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
zend_hash_init(&vars, 8, NULL, NULL, 0);
|
||||||
phpdbg_notice("Variables: %d",
|
|
||||||
zend_hash_num_elements(EG(active_symbol_table)));
|
|
||||||
|
|
||||||
zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos);
|
zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos);
|
||||||
while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var,
|
while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var,
|
||||||
NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
|
NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
|
||||||
zend_hash_get_current_data_ex(EG(active_symbol_table), (void **)&data, &pos);
|
zend_hash_get_current_data_ex(EG(active_symbol_table), (void **)&data, &pos);
|
||||||
|
|
||||||
if (*var != '_') {
|
if (*var != '_') {
|
||||||
phpdbg_write("Var: %s = ", var, *data == NULL ? "NULL" : "");
|
zend_hash_update(
|
||||||
if (data) {
|
&vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL);
|
||||||
zend_print_flat_zval_r(*data TSRMLS_CC);
|
|
||||||
phpdbg_writeln(EMPTY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
zend_hash_move_forward_ex(EG(active_symbol_table), &pos);
|
zend_hash_move_forward_ex(EG(active_symbol_table), &pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
phpdbg_notice("Variables: %d",
|
||||||
|
zend_hash_num_elements(&vars));
|
||||||
|
phpdbg_writeln("Refs\tName\t\t");
|
||||||
|
|
||||||
|
for (zend_hash_internal_pointer_reset_ex(&vars, &pos);
|
||||||
|
zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS;
|
||||||
|
zend_hash_move_forward_ex(&vars, &pos)) {
|
||||||
|
char *var;
|
||||||
|
zend_uint var_len;
|
||||||
|
zend_ulong var_idx;
|
||||||
|
zend_hash_get_current_key_ex(&vars, &var, &var_len, &var_idx, 0, &pos);
|
||||||
|
|
||||||
|
if (*data) {
|
||||||
|
phpdbg_write(
|
||||||
|
"%d\t%s$%s\t",
|
||||||
|
Z_REFCOUNT_PP(data),
|
||||||
|
Z_ISREF_PP(data) ? "&" : "", var);
|
||||||
|
|
||||||
|
zend_print_flat_zval_r(*data TSRMLS_CC);
|
||||||
|
} else {
|
||||||
|
phpdbg_write("0\t$%s", var);
|
||||||
|
}
|
||||||
|
phpdbg_writeln(EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
zend_hash_destroy(&vars);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
|
|
@ -464,11 +464,6 @@ static PHPDBG_COMMAND(run) /* {{{ */
|
||||||
zend_rebuild_symbol_table(TSRMLS_C);
|
zend_rebuild_symbol_table(TSRMLS_C);
|
||||||
}
|
}
|
||||||
|
|
||||||
zend_try {
|
|
||||||
/* last chance ... */
|
|
||||||
zend_activate_auto_globals(TSRMLS_C);
|
|
||||||
} zend_end_try();
|
|
||||||
|
|
||||||
/* clean seek state */
|
/* clean seek state */
|
||||||
PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK;
|
PHPDBG_G(flags) &= ~PHPDBG_SEEK_MASK;
|
||||||
zend_hash_clean(
|
zend_hash_clean(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue