From 270630c6286f1b2250afd2a5cfb2211a55411741 Mon Sep 17 00:00:00 2001 From: odaira Date: Wed, 4 Mar 2015 23:44:59 +0000 Subject: * random.c (random_raw_seed): Avoid calling fill_random_bytes() if the requested size is 0. AIX returns -1 for 0-byte read from /dev/urandom, while other UNIX returns 0. With this change, Random.raw_seed(0) consistently retuns "" in any UNIX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- random.c | 1 + 1 file changed, 1 insertion(+) (limited to 'random.c') diff --git a/random.c b/random.c index 82111ce69e..fed85e0a47 100644 --- a/random.c +++ b/random.c @@ -580,6 +580,7 @@ random_raw_seed(VALUE self, VALUE size) { long n = NUM2ULONG(size); VALUE buf = rb_str_new(0, n); + if (n == 0) return buf; if (fill_random_bytes(RSTRING_PTR(buf), n)) return Qnil; return buf; } -- cgit v1.2.3