From: cassowarii Date: Tue, 30 Jun 2026 13:32:40 +0000 (-0700) Subject: fix a couple bytecode compiler bugs X-Git-Url: https://www.git.cassowary.me/gitweb.cgi?a=commitdiff_plain;h=18a830922a6ce1abd2a56440f61bde72470ac148;p=sarabande.git fix a couple bytecode compiler bugs --- diff --git a/src/compile/emit.c b/src/compile/emit.c index e37f528..7e906cf 100644 --- a/src/compile/emit.c +++ b/src/compile/emit.c @@ -102,6 +102,7 @@ void compile_chunk(sbVmCompiler *cm, sbIrChunk *chunk) { location_bytes[3] = (position >> 0) & 0xFF; sbVmCompiler_overwrite_code_at(cm, lp.offset, location_bytes, 4); } + sbBuffer_set_size(&cm->label_positions, 0); } /* when compiling one line at a time, we don't know the position diff --git a/src/vm/exec.c b/src/vm/exec.c index 6491a0c..b51e653 100644 --- a/src/vm/exec.c +++ b/src/vm/exec.c @@ -356,7 +356,8 @@ void execute_instruction(hVm vm) { /* have to set new rstack space to 0 so we don't accidentally decrement * the ref count of variables from a previous stack frame (or of just garbage) */ memset(vm->rp, 0, param * sizeof(hV)); - vm->rp += param * sizeof(hV); + /* we allocate one more variable at 0 for internal use */ + vm->rp += (param + 1) * sizeof(hV); vm->fp->num_locals += param; return; case BC_LIST_GATHER: