Skip to content

Commit f24548e

Browse files
committedJul 18, 2022
Fix invalid free() during type persistence
Fixes oss-fuzz #49042
1 parent d096285 commit f24548e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎ext/opcache/tests/type_001.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Type persistene 001
3+
--EXTENSIONS--
4+
opcache
5+
--FILE--
6+
<?php
7+
function foo() {
8+
class Foo {
9+
}
10+
class y extends Foo {
11+
public (y&A)|X $y;
12+
}
13+
}
14+
foo();
15+
?>
16+
DONE
17+
--EXPECT--
18+
DONE

‎ext/opcache/zend_persist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name)
339339
static void zend_persist_type(zend_type *type) {
340340
if (ZEND_TYPE_HAS_LIST(*type)) {
341341
zend_type_list *list = ZEND_TYPE_LIST(*type);
342-
if (ZEND_TYPE_USES_ARENA(*type)) {
342+
if (ZEND_TYPE_USES_ARENA(*type) || zend_accel_in_shm(type)) {
343343
list = zend_shared_memdup_put(list, ZEND_TYPE_LIST_SIZE(list->num_types));
344344
ZEND_TYPE_FULL_MASK(*type) &= ~_ZEND_TYPE_ARENA_BIT;
345345
} else {

0 commit comments

Comments
 (0)