1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

parse.y: fix overflow

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-01-18 03:29:12 +00:00
parent 257fbc2c51
commit e6883ef688
2 changed files with 9 additions and 2 deletions

View file

@ -6191,7 +6191,6 @@ parser_heredoc_identifier(struct parser_params *p)
break;
}
p->tokenbuf[0] = p->tokenbuf[0] + toklen() - 2;
tokfix();
dispatch_scan_event(tHEREDOC_BEG);
len = p->lex.pcur - p->lex.pbeg;
@ -9155,7 +9154,7 @@ void
rb_parser_set_location_from_strterm_heredoc(struct parser_params *p, rb_strterm_heredoc_t *here, YYLTYPE *yylloc)
{
const char *eos = RSTRING_PTR(here->term);
int term_len = (int)eos[0];
long term_len = RSTRING_LEN(here->term) - 2 + (unsigned char)eos[0];
yylloc->beg_pos.lineno = (int)here->sourceline;
yylloc->beg_pos.column = (int)(here->u3.lastidx - term_len);

View file

@ -129,4 +129,12 @@ class TestAst < Test::Unit::TestCase
assert_equal([], helper.errors)
end
end
def test_column_with_long_heredoc_identifier
term = "A"*257
ast = AST.parse("<<-#{term}\n""ddddddd\n#{term}\n")
node = ast.children[1]
assert_equal("NODE_STR", node.type)
assert_equal(0, node.first_column)
end
end