diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-12 13:57:36 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-12 13:57:36 +0000 |
commit | 7a4f3769e9bd17c36bd721b38f156c0fe776f4d2 (patch) | |
tree | deec073f1e865cc52ccaee14e68146d16f1db905 /random.c | |
parent | a5236c91b048d6ba1dc04d9f107b9911036c8986 (diff) | |
download | ruby-7a4f3769e9bd17c36bd721b38f156c0fe776f4d2.tar.gz |
Random.urandom raises an exception instead of returning nil when failed
Early failure looks better in this case. Refs [Bugs #13885].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r-- | random.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -624,7 +624,8 @@ 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, FALSE)) return Qnil; + if (fill_random_bytes(RSTRING_PTR(buf), n, FALSE)) + rb_raise(rb_eRuntimeError, "failed to get urandom"); return buf; } |