[前][次][番号順一覧][スレッド一覧]

ruby-changes:43310

From: nagachika <ko1@a...>
Date: Sun, 12 Jun 2016 02:47:49 +0900 (JST)
Subject: [ruby-changes:43310] nagachika:r55384 (ruby_2_3): merge revision(s) 55154: [Backport #12418]

nagachika	2016-06-12 02:47:43 +0900 (Sun, 12 Jun 2016)

  New Revision: 55384

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55384

  Log:
    merge revision(s) 55154: [Backport #12418]
    
    * regcomp.c (compile_length_tree): return error code immediately
      if compile_length_tree raised error [Bug #12418]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/regcomp.c
    branches/ruby_2_3/test/ruby/test_regexp.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 55383)
+++ ruby_2_3/ChangeLog	(revision 55384)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Sun Jun 12 02:36:52 2016  NARUSE, Yui  <naruse@r...>
+
+	* regcomp.c (compile_length_tree): return error code immediately
+	  if compile_length_tree raised error [Bug #12418]
+
 Sun Jun 12 02:27:07 2016  NAKAMURA Usaku  <usa@r...>
 
 	* thread.c (recursive_list_access): a object id may be a Bignum.  so,
Index: ruby_2_3/test/ruby/test_regexp.rb
===================================================================
--- ruby_2_3/test/ruby/test_regexp.rb	(revision 55383)
+++ ruby_2_3/test/ruby/test_regexp.rb	(revision 55384)
@@ -1003,6 +1003,9 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_regexp.rb#L1003
     conds = {"xy"=>true, "yx"=>true, "xx"=>false, "yy"=>false}
     assert_match_each(/\A((x)|(y))(?(2)y|x)\z/, conds, bug8583)
     assert_match_each(/\A((?<x>x)|(?<y>y))(?(<x>)y|x)\z/, conds, bug8583)
+
+    bug12418 = '[ruby-core:75694] [Bug #12418]'
+    assert_raise(RegexpError, bug12418){ Regexp.new('(0?0|(?(5)||)|(?(5)||))?') }
   end
 
   def test_options_in_look_behind
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 55383)
+++ ruby_2_3/version.h	(revision 55384)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.2"
 #define RUBY_RELEASE_DATE "2016-06-12"
-#define RUBY_PATCHLEVEL 122
+#define RUBY_PATCHLEVEL 123
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 6
Index: ruby_2_3/regcomp.c
===================================================================
--- ruby_2_3/regcomp.c	(revision 55383)
+++ ruby_2_3/regcomp.c	(revision 55384)
@@ -1592,13 +1592,15 @@ compile_length_tree(Node* node, regex_t* https://github.com/ruby/ruby/blob/trunk/ruby_2_3/regcomp.c#L1592
 
   case NT_ALT:
     {
-      int n;
-
-      n = r = 0;
+      int n = 0;
+      len = 0;
       do {
-	r += compile_length_tree(NCAR(node), reg);
-	n++;
+        r = compile_length_tree(NCAR(node), reg);
+        if (r < 0) return r;
+        len += r;
+        n++;
       } while (IS_NOT_NULL(node = NCDR(node)));
+      r = len;
       r += (SIZE_OP_PUSH + SIZE_OP_JUMP) * (n - 1);
     }
     break;

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r55154


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]