Skip to content

Commit 2da8e00

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Check for zend_shared_alloc() failures
2 parents 0b524a5 + 114a0ff commit 2da8e00

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4376,6 +4376,9 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
43764376
}
43774377

43784378
jit_extension = (zend_jit_op_array_hot_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_hot_extension) + (op_array->last - 1) * sizeof(void*));
4379+
if (!jit_extension) {
4380+
return FAILURE;
4381+
}
43794382
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
43804383
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_COUNTERS;
43814384
jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) & (ZEND_HOT_COUNTERS_COUNT - 1)];
@@ -4417,6 +4420,9 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
44174420
}
44184421
}
44194422
jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension));
4423+
if (!jit_extension) {
4424+
return FAILURE;
4425+
}
44204426
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
44214427
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_FIRST_EXEC;
44224428
jit_extension->orig_handler = (void*)opline->handler;
@@ -4443,6 +4449,9 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
44434449
}
44444450
}
44454451
jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension));
4452+
if (!jit_extension) {
4453+
return FAILURE;
4454+
}
44464455
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
44474456
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_PROF_REQUEST;
44484457
jit_extension->orig_handler = (void*)opline->handler;

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7818,6 +7818,9 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
78187818
ZEND_ASSERT(sizeof(zend_op_trace_info) == sizeof(zend_op));
78197819

78207820
jit_extension = (zend_jit_op_array_trace_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_trace_extension) + (op_array->last - 1) * sizeof(zend_op_trace_info));
7821+
if (!jit_extension) {
7822+
return FAILURE;
7823+
}
78217824
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
78227825
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_TRACE;
78237826
jit_extension->op_array = op_array;

0 commit comments

Comments
 (0)