From 2d3bd9fff817f3d2d3fcce3f88590de2657ec085 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Wed, 4 Dec 2019 20:00:02 -0800 Subject: [PATCH] Handle SP_INC of NULL 'return NULL' generates an SP_INC instruction with -1 as its argument. --- vm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vm.c b/vm.c index ee0ac35..3526653 100644 --- a/vm.c +++ b/vm.c @@ -128,6 +128,8 @@ static void heap_free_slot(int32_t slot) void heap_ref(int32_t slot) { + if (slot == -1) + return; heap[slot].ref++; #ifdef DEBUG_HEAP heap[slot].ref_addr = instr_ptr;