summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mjit.c5
-rw-r--r--mjit_compile.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/mjit.c b/mjit.c
index 473f60ccb4..eca995742b 100644
--- a/mjit.c
+++ b/mjit.c
@@ -334,7 +334,8 @@ form_args(int num, ...)
for (i = len = 0; i < num; i++) {
args = va_arg(argp, char **);
n = args_len(args);
- res = (char **)realloc(res, sizeof(char *) * (len + n + 1));
+ if ((res = (char **)realloc(res, sizeof(char *) * (len + n + 1))) == NULL)
+ return NULL;
MEMCPY(res + len, args, char *, n + 1);
len += n;
}
@@ -767,6 +768,8 @@ compile_c_to_so(const char *c_file, const char *so_file)
#ifdef _MSC_VER
solen = strlen(so_file);
files[0] = p = (char *)malloc(sizeof(char) * (rb_strlen_lit("-Fe") + solen + 1));
+ if (p == NULL)
+ return FALSE;
p = append_lit(p, "-Fe");
p = append_str2(p, so_file, solen);
*p = '\0';
diff --git a/mjit_compile.c b/mjit_compile.c
index 7b8e2a7312..a44d9d9aba 100644
--- a/mjit_compile.c
+++ b/mjit_compile.c
@@ -193,6 +193,8 @@ mjit_compile(FILE *f, const struct rb_iseq_constant_body *body, const char *func
status.success = TRUE;
status.local_stack_p = !body->catch_except_p;
status.stack_size_for_pos = (int *)malloc(sizeof(int) * body->iseq_size);
+ if (status.stack_size_for_pos == NULL)
+ return FALSE;
memset(status.stack_size_for_pos, NOT_COMPILED_STACK_SIZE, sizeof(int) * body->iseq_size);
/* For performance, we verify stack size only on compilation time (mjit_compile.inc.erb) without --jit-debug */