diff --git a/ChangeLog b/ChangeLog index d8776b9070..86cc74fcd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Apr 12 15:34:59 2015 Nobuyoshi Nakada + + * parse.y (arg): fix segfault by null caused by syntax error. + [ruby-core:68851] [Bug #10957] + Sun Apr 12 15:11:16 2015 SHIBATA Hiroshi * lib/rubygems/test_case.rb: use explicitly exception class and reverted diff --git a/parse.y b/parse.y index 18116f22af..7e85d70c1e 100644 --- a/parse.y +++ b/parse.y @@ -2103,7 +2103,7 @@ arg : lhs '=' arg value_expr($3); $$ = NEW_DOT2($1, $3); if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% @@ -2117,7 +2117,7 @@ arg : lhs '=' arg value_expr($3); $$ = NEW_DOT3($1, $3); if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index ace5c8d46e..0274a11e83 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -561,6 +561,8 @@ eom bug10957 = '[ruby-core:68477] [Bug #10957]' assert_ruby_status(['-c', '-e', 'p ()..0'], "", bug10957) assert_ruby_status(['-c', '-e', 'p ()...0'], "", bug10957) + assert_syntax_error('0..%w.', /unterminated string/, bug10957) + assert_syntax_error('0...%w.', /unterminated string/, bug10957) end private