ruby-changes:12634
From: nobu <ko1@a...>
Date: Sat, 1 Aug 2009 18:51:33 +0900 (JST)
Subject: [ruby-changes:12634] Ruby:r24347 (trunk): * random.c (random_float): rejects Infinity and NaN.
nobu 2009-08-01 18:51:05 +0900 (Sat, 01 Aug 2009) New Revision: 24347 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24347 Log: * random.c (random_float): rejects Infinity and NaN. [ruby-core:24651] Modified files: trunk/ChangeLog trunk/random.c Index: ChangeLog =================================================================== --- ChangeLog (revision 24346) +++ ChangeLog (revision 24347) @@ -1,3 +1,8 @@ +Sat Aug 1 18:50:53 2009 Nobuyoshi Nakada <nobu@r...> + + * random.c (random_float): rejects Infinity and NaN. + [ruby-core:24651] + Sat Aug 1 18:34:52 2009 Nobuyoshi Nakada <nobu@r...> * tool/rbinstall.rb (gem): suppressed warnings. Index: random.c =================================================================== --- random.c (revision 24346) +++ random.c (revision 24347) @@ -196,6 +196,8 @@ #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#include <math.h> +#include <errno.h> typedef struct { VALUE seed; @@ -939,6 +941,10 @@ !NIL_P(vmax = rb_to_float(vmax)) || (vmax = range_values(vmax, &beg)) != Qfalse) { max = RFLOAT_VALUE(vmax); + if (isinf(max) || isnan(max)) { + VALUE error = INT2FIX(EDOM); + rb_exc_raise(rb_class_new_instance(1, &error, rb_eSystemCallError)); + } } else { beg = Qundef; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/