Skip to content

Commit 97b0318

Browse files
committed
Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
It crashes because it's gonna try accessing the breakpoint which was cleared by user code in `phpdbg_clear();`. Not all breakpoint data was properly cleaned. Closes GH-16953.
1 parent ae84b81 commit 97b0318

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ PHP NEWS
4747
. Fixed bug GH-16695 (phar:// tar parser and zero-length file header blocks).
4848
(nielsdos, Hans Krentel)
4949

50+
- PHPDBG:
51+
. Fixed bug GH-15208 (Segfault with breakpoint map and phpdbg_clear()).
52+
(nielsdos)
53+
5054
- SimpleXML:
5155
. Fixed bug GH-16808 (Segmentation fault in RecursiveIteratorIterator
5256
->current() with a xml element input). (nielsdos)

sapi/phpdbg/phpdbg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ PHP_FUNCTION(phpdbg_clear)
369369
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE]);
370370
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]);
371371
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]);
372+
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP]);
372373
zend_hash_clean(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]);
373374
} /* }}} */
374375

sapi/phpdbg/tests/gh15208.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
GH-15208 (Segfault with breakpoint map and phpdbg_clear())
3+
--PHPDBG--
4+
r
5+
q
6+
--FILE--
7+
<?php
8+
phpdbg_break_method("foo", "bar");
9+
phpdbg_clear();
10+
?>
11+
--EXPECTF--
12+
[Successful compilation of %s]
13+
prompt> [Breakpoint #0 added at foo::bar]
14+
[Script ended normally]
15+
prompt>

0 commit comments

Comments
 (0)