From 54eb4c1930f81998efe64661e1a6d82df915e9ba Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 12 Apr 2015 16:00:14 +0000 Subject: merge revision(s) 49964,50265: [Backport #11047] [Backport #10957] * parse.y (primary): empty parentheses at cmdarg can be null. [ruby-core:68477] [Bug #10957] * parse.y (arg): fix segfault by null caused by syntax error. [ruby-core:68851] [Bug #10957] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@50277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ parse.y | 8 ++++---- test/ruby/test_syntax.rb | 8 ++++++++ version.h | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f029243e7..b1dc9a70a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Apr 13 00:49:56 2015 Nobuyoshi Nakada + + * parse.y (arg): fix segfault by null caused by syntax error. + [ruby-core:68851] [Bug #10957] + +Mon Apr 13 00:49:56 2015 Nobuyoshi Nakada + + * parse.y (primary): empty parentheses at cmdarg can be null. + [ruby-core:68477] [Bug #10957] + Mon Apr 13 00:44:12 2015 Eric Wong * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX diff --git a/parse.y b/parse.y index 4821e08b1e..0f9a5670b6 100644 --- a/parse.y +++ b/parse.y @@ -2100,8 +2100,8 @@ arg : lhs '=' arg value_expr($1); value_expr($3); $$ = NEW_DOT2($1, $3); - if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && + $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { deferred_nodes = list_append(deferred_nodes, $$); } /*% @@ -2114,8 +2114,8 @@ arg : lhs '=' arg value_expr($1); value_expr($3); $$ = NEW_DOT3($1, $3); - if (nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { + if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->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 86c1090c30..0274a11e83 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -557,6 +557,14 @@ eom assert_syntax_error(src, /formal argument/, bug10545) end + def test_null_range_cmdarg + 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 def not_label(x) @result = x; @not_label ||= nil end diff --git a/version.h b/version.h index e25cafd163..975e122b15 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.2" #define RUBY_RELEASE_DATE "2015-04-13" -#define RUBY_PATCHLEVEL 92 +#define RUBY_PATCHLEVEL 93 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 4 -- cgit v1.2.3