summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-06 06:20:48 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-06 06:20:48 +0000
commit16d0ad48996eaf76b240cff2d8af02defe29e327 (patch)
tree6073a8a4831a3de0d72d63e53d1b0693d7685799 /sprintf.c
parent591503c0ab7a4d6bf9f90b8bdf317ee5cfa13d03 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@15713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sprintf.c b/sprintf.c
index f5b3e84..795af92 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;
}