Skip to content

Commit a6832ca

Browse files
committed
Fix incorrect assertion in property type variance check
Only one of the status has to be UNRESOLVED, the other could also be SUCCESS. Fixes oss-fuzz #19108 and oss-fuzz #19111.
1 parent 7b34e30 commit a6832ca

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Invalid property inheritance where one direction is valid and the other unresolved
3+
--FILE--
4+
<?php
5+
class A {
6+
public X|B $prop;
7+
}
8+
class B extends A {
9+
public B $prop;
10+
}
11+
?>
12+
--EXPECTF--
13+
Fatal error: Type of B::$prop must be X|B (as in class A) in %s on line %d

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ inheritance_status property_types_compatible(
966966
if (status1 == INHERITANCE_ERROR || status2 == INHERITANCE_ERROR) {
967967
return INHERITANCE_ERROR;
968968
}
969-
ZEND_ASSERT(status1 == INHERITANCE_UNRESOLVED && status2 == INHERITANCE_UNRESOLVED);
969+
ZEND_ASSERT(status1 == INHERITANCE_UNRESOLVED || status2 == INHERITANCE_UNRESOLVED);
970970
return INHERITANCE_UNRESOLVED;
971971
}
972972

0 commit comments

Comments
 (0)