]> granicus.if.org Git - php/commitdiff
Fix oplog trace with already freed closures
authorBob Weinand <bobwei9@hotmail.com>
Fri, 31 Jul 2015 00:05:49 +0000 (02:05 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Fri, 31 Jul 2015 00:06:03 +0000 (02:06 +0200)
sapi/phpdbg/phpdbg.c
sapi/phpdbg/phpdbg_list.c
sapi/phpdbg/phpdbg_opcode.c
sapi/phpdbg/phpdbg_opcode.h

index 51e6899e4e1a924968808f2ae1c8eb1fb47a8f75..874704bc6327cb25b6f2f4105518f17c9a3516d2 100644 (file)
@@ -615,25 +615,24 @@ static PHP_FUNCTION(phpdbg_end_oplog)
                zend_long insert_idx;
 
                do {
-                       zend_op_array *op_array = cur->op_array;
                        zval zero;
                        ZVAL_LONG(&zero, 0);
 
-                       if (op_array->filename != last_file) {
-                               last_file = op_array->filename;
+                       if (cur->filename != last_file) {
+                               last_file = cur->filename;
                                file_ht = insert_ht = phpdbg_add_empty_array(Z_ARR_P(return_value), last_file);
                        }
 
                        if (by_function) {
-                               if (op_array->function_name == NULL) {
+                               if (cur->function_name == NULL) {
                                        if (last_function != NULL) {
                                                insert_ht = file_ht;
                                        }
                                        last_function = NULL;
-                               } else if (op_array->function_name != last_function || op_array->scope != last_scope) {
+                               } else if (cur->function_name != last_function || cur->scope != last_scope) {
                                        zend_string *fn_name;
-                                       last_function = op_array->function_name;
-                                       last_scope = op_array->scope;
+                                       last_function = cur->function_name;
+                                       last_scope = cur->scope;
                                        if (last_scope == NULL) {
                                                fn_name = zend_string_copy(last_function);
                                        } else {
@@ -645,7 +644,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
                        }
 
                        if (by_opcode) {
-                               insert_idx = cur->op - op_array->opcodes;
+                               insert_idx = cur->op - cur->opcodes;
                        } else {
                                insert_idx = cur->op->lineno;
                        }
index 89e352a97148f08215181b11ec04ff42219e4db7..7413ded884830862d013bc02ddd351d24c9d7863 100644 (file)
@@ -320,6 +320,7 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
                        *dataptr->op_array->refcount = 2;
                        dataptr->destroy_op_array = 0;
                }
+                       ++*dataptr->op_array->refcount;
        }
 
        return ret;
index 092fcb985c565edf4b618e40b677d8fb38bda044..8b6c96434337541e75fd90737db2c267dafc4e1d 100644 (file)
@@ -202,11 +202,17 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_fl
 
        if (PHPDBG_G(oplog_list)) {
                phpdbg_oplog_entry *cur = zend_arena_alloc(&PHPDBG_G(oplog_arena), sizeof(phpdbg_oplog_entry));
+               zend_op_array *op_array = &execute_data->func->op_array;
                cur->op = (zend_op *) execute_data->opline;
-               cur->op_array = &execute_data->func->op_array;
+               cur->opcodes = op_array->opcodes;
+               cur->filename = op_array->filename;
+               cur->scope = op_array->scope;
+               cur->function_name = op_array->function_name;
                cur->next = NULL;
                PHPDBG_G(oplog_cur)->next = cur;
                PHPDBG_G(oplog_cur) = cur;
+if (!execute_data->func->op_array.filename)
+printf("ALETR");
        }
 } /* }}} */
 
index 34c9c37e500a4d010e7363af1cdf3d5f7cc31054..10d8be3f42da9aaefa8fa6e900e98a19f55d39fb 100644 (file)
@@ -30,7 +30,10 @@ void phpdbg_print_opline_ex(zend_execute_data *execute_data, zend_bool ignore_fl
 typedef struct _phpdbg_oplog_entry phpdbg_oplog_entry;
 struct _phpdbg_oplog_entry {
        phpdbg_oplog_entry *next;
-       zend_op_array *op_array;
+       zend_string *function_name;
+       zend_class_entry *scope;
+       zend_string *filename;
+       zend_op *opcodes;
        zend_op *op;
 };