1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* random.c (random_float): rejects Infinity and NaN.

[ruby-core:24651]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-08-01 09:51:05 +00:00
parent 5a5355e84f
commit 51d1c5e73b
2 changed files with 11 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sat Aug 1 18:50:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* random.c (random_float): rejects Infinity and NaN.
[ruby-core:24651]
Sat Aug 1 18:34:52 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* tool/rbinstall.rb (gem): suppressed warnings.

View file

@ -196,6 +196,8 @@ genrand_real(struct MT *mt)
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <math.h>
#include <errno.h>
typedef struct {
VALUE seed;
@ -939,6 +941,10 @@ random_float(int argc, VALUE *argv, VALUE obj)
!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;