Handle debug_print_backtrace() from main script

If there is nothing to print, the smart_str will hold a nullptr.

Fixes oss-fuzz #33334.
This commit is contained in:
Nikita Popov 2021-04-19 10:20:30 +02:00
parent d05da0f06c
commit 8bb81226c1
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,7 @@
--TEST--
Calling debug_print_backtrace() from main script
--FILE--
<?php
debug_print_backtrace();
?>
--EXPECT--

View File

@ -1715,7 +1715,9 @@ ZEND_FUNCTION(debug_print_backtrace)
zval_ptr_dtor(&backtrace);
smart_str_0(&str);
ZEND_WRITE(ZSTR_VAL(str.s), ZSTR_LEN(str.s));
if (str.s) {
ZEND_WRITE(ZSTR_VAL(str.s), ZSTR_LEN(str.s));
}
smart_str_free(&str);
}