diff options
| author | cubicdaiya <[email protected]> | 2014-03-05 11:20:39 +0900 |
|---|---|---|
| committer | cubicdaiya <[email protected]> | 2014-03-05 11:20:39 +0900 |
| commit | 016d3b93945278bb01161198978d3f449ded8ba8 (patch) | |
| tree | fc902fc4b8366a8a5585f6c0021e2ce671a901f1 /src/codegen.c | |
| parent | ba608fb38ac4f82e68c53305f59017520fa76209 (diff) | |
| download | mruby-016d3b93945278bb01161198978d3f449ded8ba8.tar.gz mruby-016d3b93945278bb01161198978d3f449ded8ba8.zip | |
fix off-by-one error in attrsym
The allocation size for null-terminated character is lacking.
In actual, it is no problem in most case
because codegen_palloc allocates more a memory size than required size.
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/codegen.c b/src/codegen.c index f30b26b00..0b4d18bba 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -704,7 +704,11 @@ attrsym(codegen_scope *s, mrb_sym a) char *name2; name = mrb_sym2name_len(s->mrb, a, &len); - name2 = (char *)codegen_palloc(s, len+1); + name2 = (char *)codegen_palloc(s, + len + + 1 /* '=' */ + + 1 /* '\0' */ + ); memcpy(name2, name, len); name2[len] = '='; name2[len+1] = '\0'; |
