Skip to content

Commit 8782e84

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Fixed #73969 - Fixed segmentation fault when debug_print_backtrace called
2 parents ab2489f + 8bda542 commit 8782e84

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PHP NEWS
2222
bugs #53838, #61655, #66173, #70925, #72254, etc. (Andrea)
2323
. Raised minimum supported Windows versions to Windows 7/Server 2008 R2.
2424
(Anatol)
25+
. Fixed bug #73969 (segfault in debug_print_backtrace). (andrewnester)
2526

2627
- BCMath:
2728
. Fixed bug #46564 (bcmod truncates fractionals). (liborm85)

Zend/zend_builtin_functions.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2466,12 +2466,17 @@ ZEND_FUNCTION(debug_print_backtrace)
24662466

24672467
if (call->func) {
24682468
func = call->func;
2469-
function_name = (func->common.scope &&
2470-
func->common.scope->trait_aliases) ?
2471-
ZSTR_VAL(zend_resolve_method_name(
2472-
(object ? object->ce : func->common.scope), func)) :
2473-
(func->common.function_name ?
2474-
ZSTR_VAL(func->common.function_name) : NULL);
2469+
zend_string *zend_function_name;
2470+
if (func->common.scope && func->common.scope->trait_aliases) {
2471+
zend_function_name = zend_resolve_method_name(object ? object->ce : func->common.scope, func);
2472+
} else {
2473+
zend_function_name = func->common.function_name;
2474+
}
2475+
if (zend_function_name != NULL) {
2476+
function_name = ZSTR_VAL(zend_function_name);
2477+
} else {
2478+
function_name = NULL;
2479+
}
24752480
} else {
24762481
func = NULL;
24772482
function_name = NULL;

tests/basic/bug73969.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
debug_print_backtrace();

tests/basic/bug73969.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #73969: segfault on debug_print_backtrace with require() call
3+
--FILE--
4+
<?php
5+
trait c2
6+
{
7+
public static function f1()
8+
{
9+
10+
}
11+
}
12+
13+
class c1
14+
{
15+
use c2
16+
{
17+
c2::f1 as f2;
18+
}
19+
20+
public static function go()
21+
{
22+
return require('bug73969.inc');
23+
}
24+
}
25+
26+
c1::go();
27+
?>
28+
--EXPECTF--
29+
#0 require() called at [%s:19]
30+
#1 c1::go() called at [%s:23]

0 commit comments

Comments
 (0)