diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2015-07-25 00:31:05 +0200 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2015-07-25 00:31:05 +0200 |
commit | b4c595dd82548575304d3b41b1c9321f50a5fefd (patch) | |
tree | 2b4b4353e05264fb01855e5bd131cad6ec9bfd8a /sapi/phpdbg/phpdbg_list.c | |
parent | cf8598593525664d7c66a7998fae68ee9268e60e (diff) | |
download | php-git-b4c595dd82548575304d3b41b1c9321f50a5fefd.tar.gz |
Fix op_arrays with opcache
Diffstat (limited to 'sapi/phpdbg/phpdbg_list.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_list.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c index 00788a0998..d00f944e9b 100644 --- a/sapi/phpdbg/phpdbg_list.c +++ b/sapi/phpdbg/phpdbg_list.c @@ -278,23 +278,52 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) { } dataptr->lines = ++line; dataptr->line[line] = endptr - data.buf; - dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); + ret = PHPDBG_G(compile_file)(&fake, type); + + if (ret == NULL) { + efree(dataptr); + return NULL; + } + + dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line); zend_hash_str_add_ptr(&PHPDBG_G(file_sources), filename, strlen(filename), dataptr); phpdbg_resolve_pending_file_break(filename); - ret = PHPDBG_G(compile_file)(&fake, type); - fake.opened_path = NULL; zend_file_handle_dtor(&fake); + return ret; +} + +zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) { + char *filename = (char *)(file->opened_path ? ZSTR_VAL(file->opened_path) : file->filename); + char resolved_path_buf[MAXPATHLEN]; + zend_op_array *ret; + phpdbg_file_source *dataptr; + + if (VCWD_REALPATH(filename, resolved_path_buf)) { + filename = resolved_path_buf; + } + + ret = PHPDBG_G(init_compile_file)(file, type); + + if (ret == NULL) { + return NULL; + } + + dataptr = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), filename, strlen(filename)); + ZEND_ASSERT(dataptr != NULL); + dataptr->op_array = ret; + dataptr->destroy_op_array = 1; if (dataptr->op_array) { if (dataptr->op_array->refcount) { ++*dataptr->op_array->refcount; } else { dataptr->op_array->refcount = emalloc(sizeof(uint32_t)); *dataptr->op_array->refcount = 2; + dataptr->destroy_op_array = 0; } } @@ -313,7 +342,7 @@ void phpdbg_free_file_source(zval *zv) { efree(data->buf); } - if (destroy_op_array(data->op_array)) { + if (!data->destroy_op_array || destroy_op_array(data->op_array)) { efree(data->op_array); } @@ -325,3 +354,8 @@ void phpdbg_init_list(void) { zend_hash_init(&PHPDBG_G(file_sources), 1, NULL, (dtor_func_t) phpdbg_free_file_source, 0); zend_compile_file = phpdbg_compile_file; } + +void phpdbg_list_update(void) { + PHPDBG_G(init_compile_file) = zend_compile_file; + zend_compile_file = phpdbg_init_compile_file; +} |