diff options
Diffstat (limited to 'sapi/phpdbg')
| -rw-r--r-- | sapi/phpdbg/phpdbg.c | 3 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 4 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_prompt.c | 4 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_watch.c | 29 |
4 files changed, 15 insertions, 25 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index a4f36eeced..ecfe7a9249 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1343,9 +1343,10 @@ int main(int argc, char **argv) /* {{{ */ struct sigaction signal_struct; signal_struct.sa_sigaction = phpdbg_signal_handler; signal_struct.sa_flags = SA_SIGINFO | SA_NODEFER; + sigemptyset(&signal_struct.sa_mask); sigio_struct.sa_sigaction = phpdbg_sigio_handler; sigio_struct.sa_flags = SA_SIGINFO; - + sigemptyset(&sigio_struct.sa_mask); address = strdup("127.0.0.1"); #endif diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index 3a7761cc64..6d5e894930 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -299,7 +299,9 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { return ret; } -void phpdbg_free_file_source(phpdbg_file_source *data) { +void phpdbg_free_file_source(zval *zv) { + phpdbg_file_source *data = Z_PTR_P(zv); + #if HAVE_MMAP if (data->map) { munmap(data->map, data->len + ZEND_MMAP_AHEAD); diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index b00952c07b..5ad3fea79d 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -607,7 +607,7 @@ static inline void phpdbg_handle_exception(void) /* {{{ */ msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("string"), 1, &rv)); } - phpdbg_writeln("exception", "name=\"%s\" file=\"%s\" line=\"%lld\"", "Uncaught %s in %s on line %lld\n%s", ZSTR_VAL(ex->ce->name), ZSTR_VAL(file), line, ZSTR_VAL(msg)); + phpdbg_writeln("exception", "name=\"%s\" file=\"%s\" line=\"" ZEND_LONG_FMT "\"", "Uncaught %s in %s on line " ZEND_LONG_FMT "\n%s", ZSTR_VAL(ex->ce->name), ZSTR_VAL(file), line, ZSTR_VAL(msg)); zend_string_release(msg); zend_string_release(file); @@ -1461,7 +1461,7 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */ line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("line"), 1, &rv)); msg = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv, ZEND_STRL("message"), 1, &rv)); - phpdbg_error("exception", "name=\"%s\" file=\"%s\" line=\"%lld\"", "Uncaught %s in %s on line %lld: %.*s", ZSTR_VAL(exception->ce->name), ZSTR_VAL(file), line, ZSTR_LEN(msg) < 80 ? ZSTR_LEN(msg) : 80, ZSTR_VAL(msg)); + phpdbg_error("exception", "name=\"%s\" file=\"%s\" line=\"" ZEND_LONG_FMT "\"", "Uncaught %s in %s on line " ZEND_LONG_FMT ": %.*s", ZSTR_VAL(exception->ce->name), ZSTR_VAL(file), line, ZSTR_LEN(msg) < 80 ? ZSTR_LEN(msg) : 80, ZSTR_VAL(msg)); zend_string_release(msg); zend_string_release(file); diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index 7452771cf2..15ae97da3a 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -442,12 +442,10 @@ static int phpdbg_create_recursive_ht_watch(phpdbg_watchpoint_t *watch) { zval *zv; zend_string *key; zend_long h; - size_t str_len; ZEND_ASSERT(watch->type == WATCH_ON_HASHTABLE); ZEND_HASH_FOREACH_KEY_VAL(HT_WATCH_HT(watch), h, key, zv) { - char *str = NULL; phpdbg_watchpoint_t *new_watch = emalloc(sizeof(phpdbg_watchpoint_t)); new_watch->flags = PHPDBG_WATCH_RECURSIVE; @@ -458,14 +456,10 @@ static int phpdbg_create_recursive_ht_watch(phpdbg_watchpoint_t *watch) { new_watch->name_in_parent = key; ++GC_REFCOUNT(key); } else { - str_len = spprintf(&str, 0, "%lld", h); - new_watch->name_in_parent = zend_string_init(str, str_len, 0); - efree(str); + new_watch->name_in_parent = strpprintf(0, ZEND_LONG_FMT, h); } - str_len = spprintf(&str, 0, "%.*s%s%s%s", (int) ZSTR_LEN(watch->str) - 2, ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", phpdbg_get_property_key(ZSTR_VAL(new_watch->name_in_parent)), (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : ""); - new_watch->str = zend_string_init(str, str_len, 0); - efree(str); + new_watch->str = strpprintf(0, "%.*s%s%s%s", (int) ZSTR_LEN(watch->str) - 2, ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", phpdbg_get_property_key(ZSTR_VAL(new_watch->name_in_parent)), (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : ""); while (Z_TYPE_P(zv) == IS_INDIRECT) { zv = Z_INDIRECT_P(zv); @@ -480,7 +474,6 @@ static int phpdbg_create_recursive_ht_watch(phpdbg_watchpoint_t *watch) { } static int phpdbg_create_recursive_zval_watch(phpdbg_watchpoint_t *watch) { - size_t str_len; HashTable *ht; zval *zvp; @@ -490,7 +483,6 @@ static int phpdbg_create_recursive_zval_watch(phpdbg_watchpoint_t *watch) { ZVAL_DEREF(zvp); if ((ht = HT_FROM_ZVP(zvp))) { - char *str = NULL; phpdbg_watchpoint_t *new_watch = emalloc(sizeof(phpdbg_watchpoint_t)); new_watch->flags = PHPDBG_WATCH_RECURSIVE; @@ -498,9 +490,7 @@ static int phpdbg_create_recursive_zval_watch(phpdbg_watchpoint_t *watch) { new_watch->parent_container = watch->parent_container; new_watch->name_in_parent = watch->name_in_parent; ++GC_REFCOUNT(new_watch->name_in_parent); - str_len = spprintf(&str, 0, "%.*s[]", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str)); - new_watch->str = zend_string_init(str, str_len, 0); - efree(str); + new_watch->str = strpprintf(0, "%.*s[]", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str)); if (Z_TYPE_P(zvp) == IS_ARRAY) { new_watch->flags |= PHPDBG_WATCH_ARRAY; @@ -513,7 +503,6 @@ static int phpdbg_create_recursive_zval_watch(phpdbg_watchpoint_t *watch) { phpdbg_create_recursive_ht_watch(new_watch); phpdbg_create_watchpoint(new_watch); - } return SUCCESS; @@ -564,24 +553,22 @@ static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_b } static void phpdbg_delete_ht_watchpoints_recursive(phpdbg_watchpoint_t *watch) { - zend_string *strkey; + zend_string *str, *strkey; zend_long numkey; - char *str; - size_t str_len; phpdbg_watchpoint_t *watchpoint; ZEND_HASH_FOREACH_KEY(HT_WATCH_HT(watch), numkey, strkey) { if (strkey) { - str_len = spprintf(&str, 0, "%.*s%s%s%s", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", phpdbg_get_property_key(ZSTR_VAL(strkey)), (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : ""); + str = strpprintf(0, "%.*s%s%s%s", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", phpdbg_get_property_key(ZSTR_VAL(strkey)), (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : ""); } else { - str_len = spprintf(&str, 0, "%.*s%s" ZEND_LONG_FMT "%s", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", numkey, (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : ""); + str = strpprintf(0, "%.*s%s" ZEND_LONG_FMT "%s", (int) ZSTR_LEN(watch->str), ZSTR_VAL(watch->str), (watch->flags & PHPDBG_WATCH_ARRAY) ? "[" : "->", numkey, (watch->flags & PHPDBG_WATCH_ARRAY) ? "]" : ""); } - if ((watchpoint = zend_hash_str_find_ptr(&PHPDBG_G(watchpoints), str, str_len))) { + if ((watchpoint = zend_hash_find_ptr(&PHPDBG_G(watchpoints), str))) { phpdbg_delete_watchpoint_recursive(watchpoint, 1); } - efree(str); + zend_string_release(str); } ZEND_HASH_FOREACH_END(); } |
