diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-04 17:15:59 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-05 09:06:29 +0200 |
commit | 4ce47709c748f912849fac2b0c157a3274e27197 (patch) | |
tree | d78461ae2cb160e98f3064e997ba982e3fc9a419 /sapi | |
parent | bc37fc57e58ae1411c7e82be7c703fdf2480bf7c (diff) | |
download | php-git-4ce47709c748f912849fac2b0c157a3274e27197.tar.gz |
Fix phpdbg watchpoints wrt. negative_array_index RFC
The implementation of that RFC changed the initial value of
`zend_array.nNextFreeElement` to `-1`; we work around that by inserting
first, and retrieving the index afterwards.
We also fix the erroneous printf specifier for the unsigned integer.
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/phpdbg/phpdbg_watch.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index c0920e0e4f..a9511fc742 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -1249,10 +1249,12 @@ static int phpdbg_watchpoint_parse_wrapper(char *name, size_t namelen, char *key if (element->child) { element = element->child; } - element->id = PHPDBG_G(watch_elements).nNextFreeElement; - zend_hash_index_add_ptr(&PHPDBG_G(watch_elements), element->id, element); - phpdbg_notice("watchadd", "index=\"%d\" variable=\"%.*s\"", "Added%s watchpoint #%d for %.*s", (element->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursive" : "", element->id, (int) ZSTR_LEN(element->str), ZSTR_VAL(element->str)); + /* work around missing API for extending an array with a new element, and getting its index */ + zend_hash_next_index_insert_ptr(&PHPDBG_G(watch_elements), element); + element->id = PHPDBG_G(watch_elements).nNextFreeElement - 1; + + phpdbg_notice("watchadd", "index=\"%d\" variable=\"%.*s\"", "Added%s watchpoint #%u for %.*s", (element->flags & PHPDBG_WATCH_RECURSIVE_ROOT) ? " recursive" : "", element->id, (int) ZSTR_LEN(element->str), ZSTR_VAL(element->str)); } PHPDBG_G(watch_tmp) = NULL; |