Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ PHP NEWS
for grouping. (Klaas Skelte van der Werf)
. Fixed bug GH-24265 (Unwind/GracefulExit discarded in
zend_fiber_execute()). (David Carlier)
. Fixed bug GH-24701 (Use-after-free on typed trait constants during
opcache preload). (sanklamm, lazerg)

- Date:
. Fixed bug GH-20503 (Assertion failure with ext/date DateInterval property
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -2848,6 +2848,7 @@ static void zend_do_traits_constant_binding(zend_class_entry *ce, zend_class_ent

Z_TRY_ADDREF(constant->value);
constant->doc_comment = constant->doc_comment ? zend_string_copy(constant->doc_comment) : NULL;
zend_type_copy_ctor(&constant->type, /* use_arena */ true, /* persistent */ false);
if (constant->attributes && (!(GC_FLAGS(constant->attributes) & IS_ARRAY_IMMUTABLE))) {
GC_ADDREF(constant->attributes);
}
Expand Down
21 changes: 21 additions & 0 deletions ext/opcache/tests/gh24701.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
GH-24701 (Use-after-free on typed trait constants during opcache preload)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.preload={PWD}/preload_gh24701.inc
--SKIPIF--
<?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
?>
--FILE--
<?php
var_dump(C::x());
var_dump(C::Y);
?>
--EXPECT--
enum(E::A)
enum(F::B)
21 changes: 21 additions & 0 deletions ext/opcache/tests/preload_gh24701.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
enum E: string {
case A = 'a';
}

enum F: string {
case B = 'b';
}

trait T {
protected const E X = E::A;
public const E|F Y = F::B;
}

class C {
use T;

public static function x() {
return self::X;
}
}
Loading