mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1115 from monaka/pr-add-null-char-to-each-symbol-name
Add null char terminate to each symbol name.
This commit is contained in:
+2
-1
@@ -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 */
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user