From a3d29a15df17219ab8bc6e8daaceacc9b92a4b79 Mon Sep 17 00:00:00 2001 From: sogaiu <983021772@users.noreply.github.com> Date: Tue, 14 Apr 2020 10:22:45 +0100 Subject: [PATCH] Check some *alloc return values --- src/core/asm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/asm.c b/src/core/asm.c index 9d31d020..d2099d83 100644 --- a/src/core/asm.c +++ b/src/core/asm.c @@ -707,6 +707,9 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int if (janet_indexed_view(x, &arr, &count)) { janet_asm_assert(&a, count == def->bytecode_length, "sourcemap must have the same length as the bytecode"); def->sourcemap = malloc(sizeof(JanetSourceMapping) * (size_t) count); + if (NULL == def->sourcemap) { + JANET_OUT_OF_MEMORY; + } for (i = 0; i < count; i++) { const Janet *tup; Janet entry = arr[i]; @@ -730,6 +733,9 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int /* Set environments */ def->environments = realloc(def->environments, def->environments_length * sizeof(int32_t)); + if (NULL == def->environments) { + JANET_OUT_OF_MEMORY; + } /* Verify the func def */ if (janet_verify(def)) {