add overflow guards to some global stacks (or value pools)
This commit is contained in:
parent
23b806cc41
commit
0a521c2314
|
@ -407,6 +407,9 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
}
|
}
|
||||||
|
|
||||||
pidx = pic->plen++;
|
pidx = pic->plen++;
|
||||||
|
if (pidx >= pic->pcapa) {
|
||||||
|
pic_abort(pic, "constant pool overflow");
|
||||||
|
}
|
||||||
pic->pool[pidx] = pic_car(pic, pic_cdr(pic, obj));
|
pic->pool[pidx] = pic_car(pic, pic_cdr(pic, obj));
|
||||||
irep->code[irep->clen].insn = OP_PUSHCONST;
|
irep->code[irep->clen].insn = OP_PUSHCONST;
|
||||||
irep->code[irep->clen].u.i = pidx;
|
irep->code[irep->clen].u.i = pidx;
|
||||||
|
@ -640,6 +643,9 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
|
||||||
case PIC_TT_BLOB: {
|
case PIC_TT_BLOB: {
|
||||||
int pidx;
|
int pidx;
|
||||||
pidx = pic->plen++;
|
pidx = pic->plen++;
|
||||||
|
if (pidx >= pic->pcapa) {
|
||||||
|
pic_abort(pic, "constant pool overflow");
|
||||||
|
}
|
||||||
pic->pool[pidx] = obj;
|
pic->pool[pidx] = obj;
|
||||||
irep->code[irep->clen].insn = OP_PUSHCONST;
|
irep->code[irep->clen].insn = OP_PUSHCONST;
|
||||||
irep->code[irep->clen].u.i = pidx;
|
irep->code[irep->clen].u.i = pidx;
|
||||||
|
|
|
@ -20,6 +20,9 @@ define_macro(pic_state *pic, const char *name, struct pic_proc *macro)
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
idx = pic->mlen++;
|
idx = pic->mlen++;
|
||||||
|
if (idx >= pic->mcapa) {
|
||||||
|
pic_abort(pic, "macro table overflow");
|
||||||
|
}
|
||||||
pic->macros[idx] = macro;
|
pic->macros[idx] = macro;
|
||||||
xh_put(pic->global_tbl, name, ~idx);
|
xh_put(pic->global_tbl, name, ~idx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue