Skip to content

Commit 17a99f2

Browse files
committed
Check for zend_shared_alloc() failures
1 parent 09d4037 commit 17a99f2

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
@@ -3790,6 +3790,9 @@ static int zend_jit_setup_hot_counters(zend_op_array *op_array)
37903790
}
37913791

37923792
jit_extension = (zend_jit_op_array_hot_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_hot_extension) + (op_array->last - 1) * sizeof(void*));
3793+
if (!jit_extension) {
3794+
return FAILURE;
3795+
}
37933796
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
37943797
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_COUNTERS;
37953798
jit_extension->counter = &zend_jit_hot_counters[zend_jit_op_array_hash(op_array) & (ZEND_HOT_COUNTERS_COUNT - 1)];
@@ -3831,6 +3834,9 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
38313834
}
38323835
}
38333836
jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension));
3837+
if (!jit_extension) {
3838+
return FAILURE;
3839+
}
38343840
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
38353841
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_FIRST_EXEC;
38363842
jit_extension->orig_handler = (void*)opline->handler;
@@ -3857,6 +3863,9 @@ ZEND_EXT_API int zend_jit_op_array(zend_op_array *op_array, zend_script *script)
38573863
}
38583864
}
38593865
jit_extension = (zend_jit_op_array_extension*)zend_shared_alloc(sizeof(zend_jit_op_array_extension));
3866+
if (!jit_extension) {
3867+
return FAILURE;
3868+
}
38603869
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
38613870
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_PROF_REQUEST;
38623871
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
@@ -7550,6 +7550,9 @@ static int zend_jit_setup_hot_trace_counters(zend_op_array *op_array)
75507550
ZEND_ASSERT(sizeof(zend_op_trace_info) == sizeof(zend_op));
75517551

75527552
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));
7553+
if (!jit_extension) {
7554+
return FAILURE;
7555+
}
75537556
memset(&jit_extension->func_info, 0, sizeof(zend_func_info));
75547557
jit_extension->func_info.flags = ZEND_FUNC_JIT_ON_HOT_TRACE;
75557558
jit_extension->op_array = op_array;

0 commit comments

Comments
 (0)