Commit 99af3183 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #1115 from monaka/pr-add-null-char-to-each-symbol-name

Add null char terminate to each symbol name.
parents 6818ec0b a9f24733
......@@ -166,7 +166,7 @@ get_syms_block_size(mrb_state *mrb, mrb_irep *irep)
size += sizeof(uint16_t); /* snl(n) */
if (irep->syms[sym_no] != 0) {
mrb_sym2name_len(mrb, irep->syms[sym_no], &len);
size += len; /* sn(n) */
size += len + 1; /* sn(n) + null char */
}
}
......@@ -194,6 +194,7 @@ write_syms_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
cur += uint16_to_bin((uint16_t)len, cur); /* length of symbol name */
memcpy(cur, name, len); /* symbol name */
cur += (uint16_t)len;
*cur++ = '\0';
}
else {
cur += uint16_to_bin(MRB_DUMP_NULL_SYM_LEN, cur); /* length of symbol name */
......
......@@ -131,7 +131,7 @@ read_rite_irep_record(mrb_state *mrb, const uint8_t *bin, uint32_t *len)
}
irep->syms[i] = mrb_intern2(mrb, (char *)src, snl);
src += snl;
src += snl + 1;
mrb_gc_arena_restore(mrb, ai);
}
......
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