Skip to content

Commit fd93f40

Browse files
committed
Fix phpGH-15120: phpdbg_print_changed_zvals working on a real copy instead.
1 parent 67ce875 commit fd93f40

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sapi/phpdbg/phpdbg_watch.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1168,8 +1168,8 @@ int phpdbg_print_changed_zvals(void) {
11681168

11691169
if (zend_hash_num_elements(PHPDBG_G(watchlist_mem)) > 0) {
11701170
/* we must not add elements to the hashtable while iterating over it (resize => read into freed memory) */
1171-
mem_list = PHPDBG_G(watchlist_mem);
1172-
PHPDBG_G(watchlist_mem) = PHPDBG_G(watchlist_mem_backup);
1171+
mem_list = zend_new_array(zend_hash_num_elements(PHPDBG_G(watchlist_mem)));
1172+
zend_hash_copy(mem_list, PHPDBG_G(watchlist_mem), (copy_ctor_func_t) zval_add_ref);
11731173

11741174
ZEND_HASH_MAP_FOREACH_NUM_KEY(mem_list, page) {
11751175
phpdbg_btree_position pos = phpdbg_btree_find_between(&PHPDBG_G(watchpoint_tree), page, page + phpdbg_pagesize);
@@ -1192,7 +1192,7 @@ int phpdbg_print_changed_zvals(void) {
11921192
phpdbg_reenable_memory_watches();
11931193

11941194
if (mem_list) {
1195-
PHPDBG_G(watchlist_mem) = mem_list;
1195+
zend_hash_destroy(mem_list);
11961196
phpdbg_reenable_memory_watches();
11971197
}
11981198

0 commit comments

Comments
 (0)