aboutsummaryrefslogtreecommitdiff
path: root/stdlib/random_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/random_r.c')
-rw-r--r--stdlib/random_r.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/stdlib/random_r.c b/stdlib/random_r.c
index d19fd1755b..677aa21ba5 100644
--- a/stdlib/random_r.c
+++ b/stdlib/random_r.c
@@ -127,7 +127,8 @@ __srandom_r (x, buf)
if (buf == NULL || buf->rand_type < TYPE_0 || buf->rand_type > TYPE_4)
return -1;
- buf->state[0] = x;
+ /* We must make sure the seed is not 0. Take arbitrarily 1 in this case. */
+ buf->state[0] = x ? x : 1;
if (buf->rand_type != TYPE_0)
{
long int i;