summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-04-12 11:20:29 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-04-12 11:46:03 +0200
commitc09b63595ef7edcaae6638932dceae531c26c3cf (patch)
treede1ca460f46c47475a6a9989e0822f100f19e9f8 /sapi
parent88bfd2ae98fb163f4b8789b0cb41f7c01eff7c3f (diff)
downloadphp-git-c09b63595ef7edcaae6638932dceae531c26c3cf.tar.gz
Fix potentially uninitialized warnings in phpdbg
Diffstat (limited to 'sapi')
-rw-r--r--sapi/phpdbg/phpdbg.c5
-rw-r--r--sapi/phpdbg/phpdbg_frame.c15
-rw-r--r--sapi/phpdbg/phpdbg_info.c8
-rw-r--r--sapi/phpdbg/phpdbg_out.c4
-rw-r--r--sapi/phpdbg/phpdbg_prompt.c47
-rw-r--r--sapi/phpdbg/phpdbg_utils.c2
-rw-r--r--sapi/phpdbg/phpdbg_wait.c4
-rw-r--r--sapi/phpdbg/phpdbg_watch.c3
8 files changed, 47 insertions, 41 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 51c6cde122..b9149287ba 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -671,11 +671,11 @@ static PHP_FUNCTION(phpdbg_end_oplog)
{
zend_string *last_file = NULL;
- HashTable *file_ht;
+ HashTable *file_ht = NULL;
zend_string *last_function = (void *)~(uintptr_t)0;
zend_class_entry *last_scope = NULL;
- HashTable *insert_ht;
+ HashTable *insert_ht = NULL;
zend_long insert_idx;
do {
@@ -717,6 +717,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
insert_idx = cur->op->lineno;
}
+ ZEND_ASSERT(insert_ht && file_ht);
{
zval *num = zend_hash_index_find(insert_ht, insert_idx);
if (!num) {
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c
index fb7acc20ce..912089ea23 100644
--- a/sapi/phpdbg/phpdbg_frame.c
+++ b/sapi/phpdbg/phpdbg_frame.c
@@ -171,7 +171,7 @@ void phpdbg_switch_frame(int frame) /* {{{ */
static void phpdbg_dump_prototype(zval *tmp) /* {{{ */
{
- zval *funcname, *class, class_zv, *type, *args, *argstmp;
+ zval *funcname, *class, class_zv, *args, *argstmp;
funcname = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("function"));
@@ -183,21 +183,22 @@ static void phpdbg_dump_prototype(zval *tmp) /* {{{ */
}
if (class) {
- type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type"));
+ zval *type = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("type"));
+
+ phpdbg_xml(" symbol=\"%s%s%s\"", Z_STRVAL_P(class), Z_STRVAL_P(type), Z_STRVAL_P(funcname));
+ phpdbg_out("%s%s%s(", Z_STRVAL_P(class), Z_STRVAL_P(type), Z_STRVAL_P(funcname));
+ } else {
+ phpdbg_xml(" symbol=\"%s\"", Z_STRVAL_P(funcname));
+ phpdbg_out("%s(", Z_STRVAL_P(funcname));
}
args = zend_hash_str_find(Z_ARRVAL_P(tmp), ZEND_STRL("args"));
-
- phpdbg_xml(" symbol=\"%s%s%s\"", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname));
-
if (args) {
phpdbg_xml(">");
} else {
phpdbg_xml(" />");
}
- phpdbg_out("%s%s%s(", class ? Z_STRVAL_P(class) : "", class ? Z_STRVAL_P(type) : "", Z_STRVAL_P(funcname));
-
if (args) {
const zend_function *func = NULL;
const zend_arg_info *arginfo = NULL;
diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c
index 167ada399a..bcec3361fc 100644
--- a/sapi/phpdbg/phpdbg_info.c
+++ b/sapi/phpdbg/phpdbg_info.c
@@ -343,11 +343,11 @@ PHPDBG_INFO(literal) /* {{{ */
PHPDBG_INFO(memory) /* {{{ */
{
size_t used, real, peak_used, peak_real;
- zend_mm_heap *heap;
+ zend_mm_heap *orig_heap = NULL;
zend_bool is_mm;
if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
- heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem());
+ orig_heap = zend_mm_set_heap(phpdbg_original_heap_sigsafe_mem());
}
if ((is_mm = is_zend_mm())) {
used = zend_memory_usage(0);
@@ -355,8 +355,8 @@ PHPDBG_INFO(memory) /* {{{ */
peak_used = zend_memory_peak_usage(0);
peak_real = zend_memory_peak_usage(1);
}
- if (PHPDBG_G(flags) & PHPDBG_IN_SIGNAL_HANDLER) {
- zend_mm_set_heap(heap);
+ if (orig_heap) {
+ zend_mm_set_heap(orig_heap);
}
if (is_mm) {
diff --git a/sapi/phpdbg/phpdbg_out.c b/sapi/phpdbg/phpdbg_out.c
index 95f27b3c6f..88981e5c6f 100644
--- a/sapi/phpdbg/phpdbg_out.c
+++ b/sapi/phpdbg/phpdbg_out.c
@@ -1030,9 +1030,8 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
} else {
phpdbg_mixed_write(fd, msg, msglen);
}
- return msglen;
}
- break;
+ return msglen;
/* no formatting on logging output */
case P_LOG:
@@ -1046,6 +1045,7 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
}
}
break;
+ EMPTY_SWITCH_DEFAULT_CASE()
}
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index c962ce52c3..e1bfeb45da 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -1687,33 +1687,33 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */
return ret;
} /* }}} */
+static inline void list_code() {
+ if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) {
+ const char *file_char = zend_get_executed_filename();
+ zend_string *file = zend_string_init(file_char, strlen(file_char), 0);
+ phpdbg_list_file(file, 3, zend_get_executed_lineno()-1, zend_get_executed_lineno());
+ efree(file);
+ }
+}
+
/* code may behave weirdly if EG(exception) is set; thus backup it */
#define DO_INTERACTIVE(allow_async_unsafe) do { \
- const zend_op *backup_opline; \
- const zend_op *before_ex; \
if (exception) { \
+ const zend_op *before_ex = EG(opline_before_exception); \
+ const zend_op *backup_opline = NULL; \
if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type)) { \
backup_opline = EG(current_execute_data)->opline; \
} \
- before_ex = EG(opline_before_exception); \
GC_ADDREF(exception); \
zend_clear_exception(); \
- } \
- if (!(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { \
- const char *file_char = zend_get_executed_filename(); \
- zend_string *file = zend_string_init(file_char, strlen(file_char), 0); \
- phpdbg_list_file(file, 3, zend_get_executed_lineno()-1, zend_get_executed_lineno()); \
- efree(file); \
- } \
- \
- switch (phpdbg_interactive(allow_async_unsafe, NULL)) { \
- zval zv; \
- case PHPDBG_LEAVE: \
- case PHPDBG_FINISH: \
- case PHPDBG_UNTIL: \
- case PHPDBG_NEXT: \
- if (exception) { \
- if (EG(current_execute_data) && EG(current_execute_data)->func && ZEND_USER_CODE(EG(current_execute_data)->func->common.type) \
+ list_code(); \
+ switch (phpdbg_interactive(allow_async_unsafe, NULL)) { \
+ zval zv; \
+ case PHPDBG_LEAVE: \
+ case PHPDBG_FINISH: \
+ case PHPDBG_UNTIL: \
+ case PHPDBG_NEXT: \
+ if (backup_opline \
&& (backup_opline->opcode == ZEND_HANDLE_EXCEPTION || backup_opline->opcode == ZEND_CATCH)) { \
EG(current_execute_data)->opline = backup_opline; \
EG(exception) = exception; \
@@ -1722,11 +1722,12 @@ int phpdbg_interactive(zend_bool allow_async_unsafe, char *input) /* {{{ */
zend_throw_exception_internal(&zv); \
} \
EG(opline_before_exception) = before_ex; \
- } \
- /* fallthrough */ \
- default: \
- goto next; \
+ } \
+ } else { \
+ list_code(); \
+ phpdbg_interactive(allow_async_unsafe, NULL); \
} \
+ goto next; \
} while (0)
void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */
diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c
index c40349f2a0..38e3d38377 100644
--- a/sapi/phpdbg/phpdbg_utils.c
+++ b/sapi/phpdbg/phpdbg_utils.c
@@ -430,7 +430,7 @@ PHPDBG_API int phpdbg_parse_variable(char *input, size_t len, HashTable *parent,
PHPDBG_API int phpdbg_parse_variable_with_arg(char *input, size_t len, HashTable *parent, size_t i, phpdbg_parse_var_with_arg_func callback, phpdbg_parse_var_with_arg_func step_cb, zend_bool silent, void *arg) {
int ret = FAILURE;
zend_bool new_index = 1;
- char *last_index;
+ char *last_index = NULL;
size_t index_len = 0;
zval *zv;
diff --git a/sapi/phpdbg/phpdbg_wait.c b/sapi/phpdbg/phpdbg_wait.c
index de0ecbe59f..738b4669f2 100644
--- a/sapi/phpdbg/phpdbg_wait.c
+++ b/sapi/phpdbg/phpdbg_wait.c
@@ -243,7 +243,7 @@ void phpdbg_webdata_decompress(char *msg, int len) {
zend_extension *extension;
zend_llist_position pos;
zval *name = NULL;
- zend_string *strkey;
+ zend_string *strkey = NULL;
extension = (zend_extension *) zend_llist_get_first_ex(&zend_extensions, &pos);
while (extension) {
@@ -257,6 +257,7 @@ void phpdbg_webdata_decompress(char *msg, int len) {
break;
}
name = NULL;
+ strkey = NULL;
} ZEND_HASH_FOREACH_END();
if (name) {
@@ -283,6 +284,7 @@ void phpdbg_webdata_decompress(char *msg, int len) {
pefree(elm, zend_extensions.persistent);
zend_extensions.count--;
} else {
+ ZEND_ASSERT(strkey);
zend_hash_del(Z_ARRVAL_P(zvp), strkey);
}
}
diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c
index 35d316b8ea..d9f9f8673f 100644
--- a/sapi/phpdbg/phpdbg_watch.c
+++ b/sapi/phpdbg/phpdbg_watch.c
@@ -1014,13 +1014,14 @@ void phpdbg_check_watchpoint(phpdbg_watchpoint_t *watch) {
}
if (watch->type == WATCH_ON_BUCKET) {
if (watch->backup.bucket.key != watch->addr.bucket->key || (watch->backup.bucket.key != NULL && watch->backup.bucket.h != watch->addr.bucket->h)) {
- phpdbg_watch_element *element;
+ phpdbg_watch_element *element = NULL;
zval *new;
ZEND_HASH_FOREACH_PTR(&watch->elements, element) {
break;
} ZEND_HASH_FOREACH_END();
+ ZEND_ASSERT(element); /* elements must be non-empty */
new = zend_symtable_find(element->parent_container, element->name_in_parent);
if (!new) {