From 46cd2f463c5668f53436076e67db59fdc33ff384 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 22 Nov 2013 04:00:39 +0000 Subject: merge revision(s) 43775: * util.c (ruby_strtod): ignore too long fraction part, which does not affect the result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_float.rb | 6 ++++++ util.c | 14 ++++++++++++-- version.h | 6 +++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b70a51d43..7a4ab22bfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Nov 22 12:46:08 2013 Nobuyoshi Nakada + + * util.c (ruby_strtod): ignore too long fraction part, which does not + affect the result. + Wed Nov 20 15:20:00 2013 CHIKANAGA Tomoyuki * test/ruby/test_thread.rb (test_mutex_unlock_on_trap): extend waiting diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index f011c2b062..e9b18f2e57 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -613,4 +613,10 @@ class TestFloat < Test::Unit::TestCase # always not flonum assert_raise(TypeError) { a = Float::INFINITY; def a.foo; end } end + + def test_long_string + assert_separately([], <<-'end;') + assert_in_epsilon(10.0, ("1."+"1"*300000).to_f*9) + end; + end end diff --git a/util.c b/util.c index 733045daa4..8ab5acf460 100644 --- a/util.c +++ b/util.c @@ -715,6 +715,11 @@ extern void *MALLOC(size_t); #else #define MALLOC malloc #endif +#ifdef FREE +extern void FREE(void*); +#else +#define FREE free +#endif #ifndef Omit_Private_Memory #ifndef PRIVATE_MEM @@ -1005,7 +1010,7 @@ Balloc(int k) #endif ACQUIRE_DTOA_LOCK(0); - if ((rv = freelist[k]) != 0) { + if (k <= Kmax && (rv = freelist[k]) != 0) { freelist[k] = rv->next; } else { @@ -1015,7 +1020,7 @@ Balloc(int k) #else len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) /sizeof(double); - if (pmem_next - private_mem + len <= PRIVATE_mem) { + if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { rv = (Bigint*)pmem_next; pmem_next += len; } @@ -1034,6 +1039,10 @@ static void Bfree(Bigint *v) { if (v) { + if (v->k > Kmax) { + FREE(v); + return; + } ACQUIRE_DTOA_LOCK(0); v->next = freelist[v->k]; freelist[v->k] = v; @@ -2097,6 +2106,7 @@ break2: for (; c >= '0' && c <= '9'; c = *++s) { have_dig: nz++; + if (nf > DBL_DIG * 2) continue; if (c -= '0') { nf += nz; for (i = 1; i < nz; i++) diff --git a/version.h b/version.h index 182ddf648f..3d92cd86cd 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2013-11-21" -#define RUBY_PATCHLEVEL 351 +#define RUBY_RELEASE_DATE "2013-11-22" +#define RUBY_PATCHLEVEL 352 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 11 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" -- cgit v1.2.3