Skip to content

Commit 6d1bebf

Browse files
committed
Fixed bug #62358 (Segfault when using traits a lot)
1 parent 64bd455 commit 6d1bebf

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PHP NEWS
1313
. Fixed bug #62744 (dangling pointers made by zend_disable_class). (Laruence)
1414
. Fixed bug #62716 (munmap() is called with the incorrect length).
1515
16-
. Fixed bug #62460 (php binaries installed as binary.dSYM). (Reeze Xia)
16+
. Fixed bug #62358 (Segfault when using traits a lot). (Laruence)
1717
. Fixed bug #62328 (implementing __toString and a cast to string fails)
1818
(Laruence)
1919
. Fixed bug #51363 (Fatal error raised by var_export() not caught by error
@@ -28,6 +28,9 @@ PHP NEWS
2828
. Fixed bug #62852 (Unserialize invalid DateTime causes crash).
2929
3030

31+
- Installation:
32+
. Fixed bug #62460 (php binaries installed as binary.dSYM). (Reeze Xia)
33+
3134
- PDO:
3235
. Fixed bug #62685 (Wrong return datatype in PDO::inTransaction()). (Laruence)
3336

Zend/tests/bug62358.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Bug #62358 (Segfault when using traits a lot)
3+
--SKIPIF--
4+
<?php
5+
if (getenv("USE_ZEND_ALLOC") !== "0") {
6+
die("skip Need Zend MM enabled");
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
12+
trait T {
13+
public function foo() {
14+
echo "from T";
15+
}
16+
}
17+
18+
interface I {
19+
public function foo();
20+
}
21+
22+
abstract class A implements I{
23+
use T;
24+
}
25+
26+
class B extends A {
27+
public function foo($var) {
28+
}
29+
}
30+
?>
31+
--EXPECTF--
32+
Strict Standards: Declaration of B::foo() should be compatible with A::foo() in %sbug62358.php on line %d

Zend/zend_compile.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3786,7 +3786,6 @@ static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int
37863786
}
37873787

37883788
fn->common.scope = ce;
3789-
fn->common.prototype = prototype;
37903789

37913790
if (prototype
37923791
&& (prototype->common.fn_flags & ZEND_ACC_IMPLEMENTED_ABSTRACT
@@ -3801,11 +3800,14 @@ static int zend_traits_merge_functions_to_class(zend_function *fn TSRMLS_DC, int
38013800
if (prototype) {
38023801
do_inheritance_check_on_method(fn, prototype TSRMLS_CC);
38033802
}
3803+
38043804
/* one more thing: make sure we properly implement an abstract method */
38053805
if (existing_fn && existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
38063806
do_inheritance_check_on_method(fn, existing_fn TSRMLS_CC);
38073807
}
38083808

3809+
fn->common.prototype = prototype;
3810+
38093811
/* delete inherited fn if the function to be added is not abstract */
38103812
if (existing_fn
38113813
&& existing_fn->common.scope != ce

0 commit comments

Comments
 (0)