summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-compiler
diff options
context:
space:
mode:
authordearblue <[email protected]>2019-04-14 16:16:05 +0900
committerdearblue <[email protected]>2019-04-14 16:16:05 +0900
commitdac0f3f5e85d067b15c44a933b151acefb2d5598 (patch)
tree51f4a5eedc7c514518396abdd5436ae1207e6425 /mrbgems/mruby-compiler
parentc2fa935fee31c201ba4b07e72690e78a3094cf68 (diff)
downloadmruby-dac0f3f5e85d067b15c44a933b151acefb2d5598.tar.gz
mruby-dac0f3f5e85d067b15c44a933b151acefb2d5598.zip
Fix string index for appending
`sizeof(string-literal)` is included `'\0'` character
Diffstat (limited to 'mrbgems/mruby-compiler')
-rw-r--r--mrbgems/mruby-compiler/core/parse.y6
1 files changed, 3 insertions, 3 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index f6b883b9e..7838b6dfb 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -5715,9 +5715,9 @@ parser_yylex(parser_state *p)
const char hexdigits[] = "0123456789ABCDEF";
strcpy(buf, s);
- buf[sizeof(s)] = hexdigits[(c & 0xf0) >> 4];
- buf[sizeof(s)+1] = hexdigits[(c & 0x0f)];
- buf[sizeof(s)+2] = 0;
+ buf[sizeof(s)-1] = hexdigits[(c & 0xf0) >> 4];
+ buf[sizeof(s)] = hexdigits[(c & 0x0f)];
+ buf[sizeof(s)+1] = 0;
yyerror(p, buf);
goto retry;
}