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

ruby-changes:17187

From: naruse <ko1@a...>
Date: Mon, 6 Sep 2010 10:00:37 +0900 (JST)
Subject: [ruby-changes:17187] Ruby:r29187 (trunk): * util.c (ruby_strtod): check there is at least 1 digit after

naruse	2010-09-06 10:00:29 +0900 (Mon, 06 Sep 2010)

  New Revision: 29187

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29187

  Log:
    * util.c (ruby_strtod): check there is at least 1 digit after
      "0x" before ".". [ruby-dev:42183] #3790

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_float.rb
    trunk/util.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29186)
+++ ChangeLog	(revision 29187)
@@ -1,3 +1,8 @@
+Mon Sep  6 09:47:24 2010  NARUSE, Yui  <naruse@r...>
+
+	* util.c (ruby_strtod): check there is at least 1 digit after
+	  "0x" before ".". [ruby-dev:42183] #3790
+
 Mon Sep  6 09:44:50 2010  NARUSE, Yui  <naruse@r...>
 
 	* util.c (ruby_strtod): check integr overflow.
Index: util.c
===================================================================
--- util.c	(revision 29186)
+++ util.c	(revision 29187)
@@ -2123,10 +2123,11 @@
 	    s0 = ++s;
 	    adj = 0;
 
-	    while (*++s && (s1 = strchr(hexdigit, *s))) {
+	    if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
+	    do {
 		adj *= 16;
 		adj += (s1 - hexdigit) & 15;
-	    }
+	    } while (*++s && (s1 = strchr(hexdigit, *s)));
 
 	    if (*s == '.') {
 		aadj = 1.;
Index: test/ruby/test_float.rb
===================================================================
--- test/ruby/test_float.rb	(revision 29186)
+++ test/ruby/test_float.rb	(revision 29187)
@@ -447,6 +447,7 @@
     assert(!Float(([1] * 10000).join("_")).infinite?) # is it really OK?
     assert_raise(ArgumentError) { Float("1.0\x001") }
     assert_equal(15.9375, Float('0xf.fp0'))
+    assert_raise(ArgumentError) { Float('0x') }
     assert_raise(ArgumentError) { Float('0xf.fp') }
     assert_equal(Float::INFINITY, Float('0xf.fp1000000000000000'))
     assert_equal(1, suppress_warning {Float("1e10_00")}.infinite?)

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

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