Fix out of bound access in `parse.y`.

parent 9cebddf9
......@@ -284,7 +284,7 @@ local_var_p(parser_state *p, mrb_sym sym)
int i;
if (!v) break;
for (i=0; i < ir->nlocals; i++) {
for (i=0; i+1 < ir->nlocals; i++) {
if (v[i] == sym) return TRUE;
}
if (MRB_PROC_SCOPE_P(u)) break;
......
......@@ -347,7 +347,7 @@ local_var_p(parser_state *p, mrb_sym sym)
int i;
if (!v) break;
for (i=0; i < ir->nlocals; i++) {
for (i=0; i+1 < ir->nlocals; i++) {
if (v[i] == sym) return TRUE;
}
if (MRB_PROC_SCOPE_P(u)) break;
......
......@@ -434,7 +434,7 @@ read_lv_record(mrb_state *mrb, const uint8_t *start, mrb_irep *irep, size_t *rec
irep->lv = lv = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym) * (irep->nlocals - 1));
for (i = 0; i + 1< irep->nlocals; ++i) {
for (i = 0; i + 1 < irep->nlocals; ++i) {
uint16_t const sym_idx = bin_to_uint16(bin);
bin += sizeof(uint16_t);
if (sym_idx == RITE_LV_NULL_MARK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment