com php-src: Fix invalid access to interned strings after they are freed in phpdbg: sapi/phpdbg/phpdbg_list.c
| From: | Bob Weinand | Date: | Sat, 01 Oct 2016 09:46:21 +0000 |
| Subject: | com php-src: Fix invalid access to interned strings after they are freed in phpdbg: sapi/phpdbg/phpdbg_list.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94809@lists.php.net to get a copy of this message | ||
Commit: 3280a29ee5194a6e627f8eb87492b64ff1959a0e
Author: Bob Weinand <bobwei9@hotmail.com> Sat, 1 Oct 2016 10:46:21 +0100
Parents: 12967bc3465cd469bb0a130173b17d7b2b3bf755
Branches: PHP-7.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3280a29ee5194a6e627f8eb87492b64ff1959a0e
Log:
Fix invalid access to interned strings after they are freed in phpdbg
Changed paths:
M sapi/phpdbg/phpdbg_list.c
Diff:
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 6895bea..74d35c7 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -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;