Skip to content

Commit

Permalink
Fix invalid access to interned strings after they are freed in phpdbg
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoebi committed Oct 1, 2016
1 parent 12967bc commit 3280a29
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sapi/phpdbg/phpdbg_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,17 @@ zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
dataptr = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), filename, strlen(filename));
ZEND_ASSERT(dataptr != NULL);

if (op_array->vars) {
int i;
/* un-intern these strings to prevent zend_restore_strings from invalidating our string pointers too early */
for (i = 0; i < op_array->last_var; i++) {
zend_string **s = op_array->vars + i;
if (ZSTR_IS_INTERNED(*s)) {
*s = zend_string_init(ZSTR_VAL(*s), ZSTR_LEN(*s), 0);
}
}
}

dataptr->op_array = *op_array;
if (dataptr->op_array.refcount) {
++*dataptr->op_array.refcount;
Expand Down

0 comments on commit 3280a29

Please sign in to comment.