Skip to content

Commit 8bb8122

Browse files
committed
Handle debug_print_backtrace() from main script
If there is nothing to print, the smart_str will hold a nullptr. Fixes oss-fuzz #33334.
1 parent d05da0f commit 8bb8122

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
Calling debug_print_backtrace() from main script
3+
--FILE--
4+
<?php
5+
debug_print_backtrace();
6+
?>
7+
--EXPECT--

Zend/zend_builtin_functions.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,9 @@ ZEND_FUNCTION(debug_print_backtrace)
17151715
zval_ptr_dtor(&backtrace);
17161716

17171717
smart_str_0(&str);
1718-
ZEND_WRITE(ZSTR_VAL(str.s), ZSTR_LEN(str.s));
1718+
if (str.s) {
1719+
ZEND_WRITE(ZSTR_VAL(str.s), ZSTR_LEN(str.s));
1720+
}
17191721
smart_str_free(&str);
17201722
}
17211723

0 commit comments

Comments
 (0)