summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sprintf.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f277ed0..cf507ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Mar 6 15:16:55 2008 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * sprintf.c (rb_str_format): casting double to long is undefined
+ if the interger part of double is out of the range of long.
+
Thu Mar 6 15:11:40 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
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;
}