summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-04-24 09:06:12 +0900
committerGitHub <[email protected]>2017-04-24 09:06:12 +0900
commit72bdb6a93f5f80c0b84f8db21464afcf74103ada (patch)
tree1c3e9fd1c073cc851668666a44a3e1659f1b9c31
parent809b7ca3f4e93dc44ec4ba7d2cf3716834f25887 (diff)
parentd54f9f8f783cae5a96fc66c74960f18488fd315b (diff)
downloadmruby-72bdb6a93f5f80c0b84f8db21464afcf74103ada.tar.gz
mruby-72bdb6a93f5f80c0b84f8db21464afcf74103ada.zip
Merge pull request #3631 from nobu/bug/embeddoc-terminator-word
Fix embedded document with unterminated terminator
-rw-r--r--mrbgems/mruby-compiler/bintest/mrbc.rb9
-rw-r--r--mrbgems/mruby-compiler/core/parse.y2
2 files changed, 10 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/bintest/mrbc.rb b/mrbgems/mruby-compiler/bintest/mrbc.rb
index e27365edb..f4d9208b3 100644
--- a/mrbgems/mruby-compiler/bintest/mrbc.rb
+++ b/mrbgems/mruby-compiler/bintest/mrbc.rb
@@ -19,3 +19,12 @@ assert('parsing function with void argument') do
assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus
end
+
+assert('embedded document with invalid terminator') do
+ a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb')
+ a.write("=begin\n=endx\n")
+ a.flush
+ result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1`
+ assert_equal "#{a.path}:3:0: embedded document meets end of file", result.chomp
+ assert_equal 1, $?.exitstatus
+end
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index 3e4e146f0..7d66bf21f 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -3580,7 +3580,7 @@ skips(parser_state *p, const char *s)
/* skip until first char */
for (;;) {
c = nextc(p);
- if (c < 0) return c;
+ if (c < 0) return FALSE;
if (c == '\n') {
p->lineno++;
p->column = 0;