From fcacee059599bb2ac147bc4e4c48f1300cdd04f9 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 3 Apr 2014 19:34:08 +0000 Subject: [PATCH] Fixed deleting watchpoints (plus error in btree_delete) --- phpdbg_btree.c | 2 +- phpdbg_watch.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpdbg_btree.c b/phpdbg_btree.c index 9eba9823de1..8fc2561e047 100644 --- a/phpdbg_btree.c +++ b/phpdbg_btree.c @@ -202,7 +202,7 @@ check_branch_existence: if (last_dual_branch->branches[last_dual_branch_branch] == last_dual_branch + 1) { phpdbg_btree_branch *original_branch = last_dual_branch->branches[!last_dual_branch_branch]; - memcpy(last_dual_branch + 1, last_dual_branch->branches[!last_dual_branch_branch], i_last_dual_branch * sizeof(phpdbg_btree_branch)); + memcpy(last_dual_branch + 1, last_dual_branch->branches[!last_dual_branch_branch], (i_last_dual_branch + 1) * sizeof(phpdbg_btree_branch)); efree(last_dual_branch->branches[!last_dual_branch_branch]); last_dual_branch->branches[!last_dual_branch_branch] = last_dual_branch + 1; diff --git a/phpdbg_watch.c b/phpdbg_watch.c index 6b1a42ddbe3..50fa3927396 100644 --- a/phpdbg_watch.c +++ b/phpdbg_watch.c @@ -208,12 +208,12 @@ static int phpdbg_create_recursive_watchpoint(phpdbg_watchpoint_t *watch TSRMLS_ return SUCCESS; } -static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch TSRMLS_DC) { +static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch, zend_bool user_request TSRMLS_DC) { if (watch->type == WATCH_ON_HASHTABLE || (watch->type == WATCH_ON_ZVAL && (Z_TYPE_P(watch->addr.zv) == IS_ARRAY || Z_TYPE_P(watch->addr.zv) == IS_OBJECT))) { HashTable *ht; phpdbg_btree_result *result; - if (watch->type == WATCH_ON_HASHTABLE) { + if (watch->type == WATCH_ON_HASHTABLE && user_request) { HashPosition position; zval **zv; zval key; @@ -235,7 +235,7 @@ static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch TSRMLS_ } if (zend_hash_find(&PHPDBG_G(watchpoints), str, str_len, (void **) &watchpoint) == SUCCESS) { - phpdbg_delete_watchpoint_recursive(*watchpoint TSRMLS_CC); + phpdbg_delete_watchpoint_recursive(*watchpoint, 1 TSRMLS_CC); } } } else { @@ -249,7 +249,7 @@ static int phpdbg_delete_watchpoint_recursive(phpdbg_watchpoint_t *watch TSRMLS_ } if ((result = phpdbg_btree_find(&PHPDBG_G(watchpoint_tree), (zend_ulong) ht))) { - phpdbg_delete_watchpoint_recursive((phpdbg_watchpoint_t *) result->ptr TSRMLS_CC); + phpdbg_delete_watchpoint_recursive((phpdbg_watchpoint_t *) result->ptr, user_request TSRMLS_CC); } } } @@ -269,7 +269,7 @@ static int phpdbg_delete_watchpoint(phpdbg_watchpoint_t *tmp_watch TSRMLS_DC) { watch = result->ptr; if (watch->flags & PHPDBG_WATCH_RECURSIVE) { - ret = phpdbg_delete_watchpoint_recursive(watch TSRMLS_CC); + ret = phpdbg_delete_watchpoint_recursive(watch, 1 TSRMLS_CC); } else { ret = zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); } @@ -447,7 +447,7 @@ void phpdbg_watch_HashTable_dtor(zval **zv) { phpdbg_notice("%.*s was removed, removing watchpoint%s", (int)watch->str_len, watch->str, (watch->flags & PHPDBG_WATCH_RECURSIVE)?" recursively":""); if (watch->flags & PHPDBG_WATCH_RECURSIVE) { - phpdbg_delete_watchpoint_recursive(watch TSRMLS_CC); + phpdbg_delete_watchpoint_recursive(watch, 0 TSRMLS_CC); } else { zend_hash_del(&PHPDBG_G(watchpoints), watch->str, watch->str_len); }