summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMasaki Muranaka <[email protected]>2013-03-30 13:17:29 +0900
committerMasaki Muranaka <[email protected]>2013-03-30 13:17:29 +0900
commita9f247337798036de831a5842dca94adcac2cfdc (patch)
tree1fea59700586465b150bab0274a89818f04e422a /src
parent6818ec0b38fdf2bd027b2088ed99606d74358d99 (diff)
downloadmruby-a9f247337798036de831a5842dca94adcac2cfdc.tar.gz
mruby-a9f247337798036de831a5842dca94adcac2cfdc.zip
Add null char terminate to each symbol name.
Diffstat (limited to 'src')
-rw-r--r--src/dump.c3
-rw-r--r--src/load.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/dump.c b/src/dump.c
index 578a22202..57fa7f612 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -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 */
diff --git a/src/load.c b/src/load.c
index a2f685742..c350cb1a3 100644
--- a/src/load.c
+++ b/src/load.c
@@ -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);
}