Skip to content

Commit e8f004d

Browse files
committed
Fixed bug #64966 (segfault in zend_do_fcall_common_helper_SPEC)
1 parent 1aee7ad commit e8f004d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2013, PHP 5.3.27
4+
45
- Core:
6+
. Fixed bug #64966 (segfault in zend_do_fcall_common_helper_SPEC). (Laruence)
57
. Fixed bug #64960 (Segfault in gc_zval_possible_root). (Laruence)
68
. Fixed bug #64934 (Apache2 TS crash with get_browser()). (Anatol)
79

Zend/tests/bug64966.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
Bug #64966 (segfault in zend_do_fcall_common_helper_SPEC)
3+
--FILE--
4+
<?php
5+
error_reporting(E_ALL);
6+
set_error_handler(function($error) { throw new Exception(); }, E_RECOVERABLE_ERROR);
7+
8+
function test($func) {
9+
$a = $func("");
10+
return true;
11+
}
12+
class A {
13+
public function b() {
14+
test("strlen");
15+
test("iterator_apply");
16+
}
17+
}
18+
19+
$a = new A();
20+
$a->b();
21+
?>
22+
--EXPECTF--
23+
Fatal error: Uncaught exception 'Exception' in %sbug64966.php:3
24+
Stack trace:
25+
#0 [internal function]: {closure}(4096, 'Argument 1 pass...', '/home/huixinche...', 6, Array)
26+
#1 %sbug64966.php(6): iterator_apply('')
27+
#2 %sbug64966.php(12): test('iterator_apply')
28+
#3 %sbug64966.php(17): A->b()
29+
#4 {main}
30+
thrown in %sbug64966.php on line 3

Zend/zend_vm_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,8 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
23272327
if (!RETURN_VALUE_USED(opline)) {
23282328
zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);
23292329
}
2330+
} else if (RETURN_VALUE_USED(opline)) {
2331+
EX_T(opline->result.u.var).var.ptr = NULL;
23302332
}
23312333
} else if (EX(function_state).function->type == ZEND_USER_FUNCTION) {
23322334
EX(original_return_value) = EG(return_value_ptr_ptr);

Zend/zend_vm_execute.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
327327
if (!RETURN_VALUE_USED(opline)) {
328328
zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr);
329329
}
330+
} else if (RETURN_VALUE_USED(opline)) {
331+
EX_T(opline->result.u.var).var.ptr = NULL;
330332
}
331333
} else if (EX(function_state).function->type == ZEND_USER_FUNCTION) {
332334
EX(original_return_value) = EG(return_value_ptr_ptr);

0 commit comments

Comments
 (0)