From 901bd5da86bf4bbae954b0856ffc67aebf120798 Mon Sep 17 00:00:00 2001 From: usa Date: Thu, 6 Mar 2008 06:20:48 +0000 Subject: * sprintf.c (rb_str_format): casting double to long is undefined if the interger part of double is out of the range of long. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sprintf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sprintf.c') diff --git a/sprintf.c b/sprintf.c index f5b3e8474..795af9237 100644 --- a/sprintf.c +++ b/sprintf.c @@ -540,7 +540,8 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) bin_retry: switch (TYPE(val)) { case T_FLOAT: - if (FIXABLE((long)RFLOAT_VALUE(val))) { + if (RFLOAT_VALUE(val) <= LONG_MAX && + RFLOAT_VALUE(val) >= LONG_MIN) { val = LONG2FIX((long)RFLOAT_VALUE(val)); goto bin_retry; } -- cgit