Skip to content

Commit 4abf423

Browse files
committed
Merge branch 'PHP-7.2'
2 parents 66cf76e + 14b2270 commit 4abf423

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #76520 (Object creation leaks memory when executed over HTTP).
77
(Nikita)
8+
. Fixed bug #76502 (Chain of mixed exceptions and errors does not serialize
9+
properly). (Nikita)
810

911
- FPM:
1012
. Fixed bug #73342 (Vulnerability in php-fpm by changing stdin to

Zend/tests/bug76502.phpt

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Bug #76502: Chain of mixed exceptions and errors does not serialize properly
3+
--FILE--
4+
<?php
5+
6+
$examples = [
7+
"Exception(Exception())" => new Exception("outer", 0, new Exception("inner")),
8+
"Error(Error())" => new Error("outer", 0, new Error("inner")),
9+
"Error(Exception())" => new Error("outer", 0, new Exception("inner")),
10+
"Exception(Error())" => new Exception("outer", 0, new Error("inner"))
11+
];
12+
13+
foreach ($examples as $name => $example) {
14+
$processed = unserialize(serialize($example));
15+
$processedPrev = $processed->getPrevious();
16+
echo "---- $name ----\n";
17+
echo "before: ", get_class($example), ".previous == ",
18+
get_class($example->getPrevious()), "\n";
19+
echo "after : ", get_class($processed), ".previous == ",
20+
$processedPrev ? get_class($processedPrev) : "null", "\n";
21+
}
22+
23+
?>
24+
--EXPECT--
25+
---- Exception(Exception()) ----
26+
before: Exception.previous == Exception
27+
after : Exception.previous == Exception
28+
---- Error(Error()) ----
29+
before: Error.previous == Error
30+
after : Error.previous == Error
31+
---- Error(Exception()) ----
32+
before: Error.previous == Exception
33+
after : Error.previous == Exception
34+
---- Exception(Error()) ----
35+
before: Exception.previous == Error
36+
after : Exception.previous == Error

Zend/zend_exceptions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ ZEND_METHOD(exception, __wakeup)
325325
CHECK_EXC_TYPE(ZEND_STR_TRACE, IS_ARRAY);
326326
pvalue = zend_read_property(i_get_exception_base(object), object, "previous", sizeof("previous")-1, 1, &value);
327327
if (pvalue && Z_TYPE_P(pvalue) != IS_NULL && (Z_TYPE_P(pvalue) != IS_OBJECT ||
328-
!instanceof_function(Z_OBJCE_P(pvalue), i_get_exception_base(object)) ||
328+
!instanceof_function(Z_OBJCE_P(pvalue), zend_ce_throwable) ||
329329
pvalue == object)) {
330330
zend_unset_property(i_get_exception_base(object), object, "previous", sizeof("previous")-1);
331331
}

0 commit comments

Comments
 (0)