aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mjit.c5
-rw-r--r--mjit_worker.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/mjit.c b/mjit.c
index 4db2498a3c..2f2cfc71ed 100644
--- a/mjit.c
+++ b/mjit.c
@@ -291,6 +291,11 @@ mjit_add_iseq_to_process(const rb_iseq_t *iseq)
return;
node = create_list_node(iseq->body->jit_unit);
+ if (node == NULL) {
+ mjit_warning("failed to allocate a node to be added to unit_queue");
+ return;
+ }
+
CRITICAL_SECTION_START(3, "in add_iseq_to_process");
add_to_list(node, &unit_queue);
if (active_units.length >= mjit_opts.max_cache_size) {
diff --git a/mjit_worker.c b/mjit_worker.c
index c37bec8e29..adc96abde0 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -319,6 +319,7 @@ static struct rb_mjit_unit_node *
create_list_node(struct rb_mjit_unit *unit)
{
struct rb_mjit_unit_node *node = (struct rb_mjit_unit_node *)calloc(1, sizeof(struct rb_mjit_unit_node)); /* To prevent GC, don't use ZALLOC */
+ if (node == NULL) return NULL;
node->unit = unit;
return node;
}
@@ -1116,6 +1117,11 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
if ((uintptr_t)func > (uintptr_t)LAST_JIT_ISEQ_FUNC) {
struct rb_mjit_unit_node *node = create_list_node(unit);
+ if (node == NULL) {
+ mjit_warning("failed to allocate a node to be added to active_units");
+ return (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC;
+ }
+
CRITICAL_SECTION_START(3, "end of jit");
add_to_list(node, &active_units);
if (unit->iseq)