Skip to content

Commit 114a0ff

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Check for zend_shared_alloc() failures
2 parents 8168d31 + 17a99f2 commit 114a0ff

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
@@ -4392,6 +4392,9 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
43924392
}
43934393

43944394
jit_extension = (zend_jit_op_array_hot_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_hot_extension) + (op_array->last - 1) * sizeof(void*));
4395+
if (!jit_extension) {
4396+
return FAILURE;
4397+
}
43954398
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
43964399
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_COUNTERS;
43974400
jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) & (ZEND_HOT_COUNTERS_COUNT - 1)];
@@ -4433,6 +4436,9 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
44334436
}
44344437
}
44354438
jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension));
4439+
if (!jit_extension) {
4440+
return FAILURE;
4441+
}
44364442
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
44374443
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_FIRST_EXEC;
44384444
jit_extension->orig_handler = (void*)opline->handler;
@@ -4459,6 +4465,9 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
44594465
}
44604466
}
44614467
jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension));
4468+
if (!jit_extension) {
4469+
return FAILURE;
4470+
}
44624471
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
44634472
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_PROF_REQUEST;
44644473
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
@@ -7820,6 +7820,9 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
78207820
ZEND_ASSERT(sizeof(zend_op_trace_info) == sizeof(zend_op));
78217821

78227822
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));
7823+
if (!jit_extension) {
7824+
return FAILURE;
7825+
}
78237826
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
78247827
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_TRACE;
78257828
jit_extension->op_array = op_array;

0 commit comments

Comments
 (0)