diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-06-17 12:18:48 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-06-17 12:18:48 +0900 |
| commit | c1901539a885de7e9e3998c7e59ec9286d24fd88 (patch) | |
| tree | 78e77992a76241602e9c600d2984a186a53eb06a /mrbgems/mruby-struct | |
| parent | ab5ffb308b65a365d5f68662f30b223ccbde3b03 (diff) | |
| parent | ee955b58f7818248626e3aa66a6bff17dbd6060f (diff) | |
| download | mruby-c1901539a885de7e9e3998c7e59ec9286d24fd88.tar.gz mruby-c1901539a885de7e9e3998c7e59ec9286d24fd88.zip | |
Merge pull request #4502 from shuujii/adjust-allocation-size-in-mrb_id_attrset-mruby-struct
Adjust allocation size in `mrb_id_attrset()` (`mruby-struct`)
Diffstat (limited to 'mrbgems/mruby-struct')
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 40914acc9..30ef8d110 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -129,10 +129,9 @@ mrb_id_attrset(mrb_state *mrb, mrb_sym id) mrb_sym mid; name = mrb_sym2name_len(mrb, id, &len); - buf = (char *)mrb_malloc(mrb, (size_t)len+2); + buf = (char *)mrb_malloc(mrb, (size_t)len+1); memcpy(buf, name, (size_t)len); buf[len] = '='; - buf[len+1] = '\0'; mid = mrb_intern(mrb, buf, len+1); mrb_free(mrb, buf); |
