summaryrefslogtreecommitdiffhomepage
path: root/src/load.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-05-19 18:39:37 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-05-19 18:39:37 +0900
commit54c2dcf231f1dce1972a3b55fee1123ff8ff0229 (patch)
tree94a432a8f8fb9e626d0da652ba6fe00873036efe /src/load.c
parent91a025b1e663f9d6516c28bbfbc6cf03225e46fc (diff)
downloadmruby-54c2dcf231f1dce1972a3b55fee1123ff8ff0229.tar.gz
mruby-54c2dcf231f1dce1972a3b55fee1123ff8ff0229.zip
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.
Diffstat (limited to 'src/load.c')
-rw-r--r--src/load.c14
1 files changed, 10 insertions, 4 deletions
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);
}