diff --git a/src/codegen.c b/src/codegen.c index 4defaa34..6aac14b5 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -407,6 +407,9 @@ codegen(codegen_state *state, pic_value obj, bool tailpos) } pidx = pic->plen++; + if (pidx >= pic->pcapa) { + pic_abort(pic, "constant pool overflow"); + } pic->pool[pidx] = pic_car(pic, pic_cdr(pic, obj)); irep->code[irep->clen].insn = OP_PUSHCONST; irep->code[irep->clen].u.i = pidx; @@ -640,6 +643,9 @@ codegen(codegen_state *state, pic_value obj, bool tailpos) case PIC_TT_BLOB: { int pidx; pidx = pic->plen++; + if (pidx >= pic->pcapa) { + pic_abort(pic, "constant pool overflow"); + } pic->pool[pidx] = obj; irep->code[irep->clen].insn = OP_PUSHCONST; irep->code[irep->clen].u.i = pidx; diff --git a/src/expand.c b/src/expand.c index 7b32ef4f..a8752c47 100644 --- a/src/expand.c +++ b/src/expand.c @@ -20,6 +20,9 @@ define_macro(pic_state *pic, const char *name, struct pic_proc *macro) int idx; idx = pic->mlen++; + if (idx >= pic->mcapa) { + pic_abort(pic, "macro table overflow"); + } pic->macros[idx] = macro; xh_put(pic->global_tbl, name, ~idx); }