aboutsummaryrefslogtreecommitdiff
path: root/stdlib/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/random.c')
-rw-r--r--stdlib/random.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/stdlib/random.c b/stdlib/random.c
index 3ed610dd9c..967dec3539 100644
--- a/stdlib/random.c
+++ b/stdlib/random.c
@@ -234,16 +234,17 @@ __initstate (seed, arg_state, n)
size_t n;
{
int32_t *ostate;
+ int ret;
__libc_lock_lock (lock);
ostate = &unsafe_state.state[-1];
- __initstate_r (seed, arg_state, n, &unsafe_state);
+ ret = __initstate_r (seed, arg_state, n, &unsafe_state);
__libc_lock_unlock (lock);
- return (char *) ostate;
+ return ret == -1 ? NULL : (char *) ostate;
}
weak_alias (__initstate, initstate)