From 54c2dcf231f1dce1972a3b55fee1123ff8ff0229 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 19 May 2014 18:39:37 +0900 Subject: allow NULL (no variable) in lvar section of mrb format; fix #2294 This fix use UINT16_MAX for NULL symbol tag, that means maximum symbol length is not UINT16_MAX-1. --- src/load.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/load.c') diff --git a/src/load.c b/src/load.c index 668e6681e..0a877dd78 100644 --- a/src/load.c +++ b/src/load.c @@ -411,12 +411,18 @@ read_lv_record(mrb_state *mrb, const uint8_t *start, mrb_irep *irep, size_t *rec for (i = 0; i + 1< irep->nlocals; ++i) { uint16_t const sym_idx = bin_to_uint16(bin); bin += sizeof(uint16_t); - if (sym_idx >= syms_len) { - return MRB_DUMP_GENERAL_FAILURE; + if (sym_idx == RITE_LV_NULL_MARK) { + irep->lv[i].name = 0; + irep->lv[i].r = 0; } - irep->lv[i].name = syms[sym_idx]; + else { + if (sym_idx >= syms_len) { + return MRB_DUMP_GENERAL_FAILURE; + } + irep->lv[i].name = syms[sym_idx]; - irep->lv[i].r = bin_to_uint16(bin); + irep->lv[i].r = bin_to_uint16(bin); + } bin += sizeof(uint16_t); } -- cgit v1.2.3