aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2013-04-29 21:02:16 +0200
committerAndreas Jaeger <aj@suse.de>2013-04-29 21:02:16 +0200
commit9ce3b2cbd245abedc6cff147a1b91566e340edb1 (patch)
tree7f87cd0284daa1116fded62b7e1c66f063d9c64e /stdlib
parentb1a36ceb3bb0c8de45fc2024e57529e02ee3adef (diff)
downloadglibc-9ce3b2cbd245abedc6cff147a1b91566e340edb1.zip
glibc-9ce3b2cbd245abedc6cff147a1b91566e340edb1.tar.gz
glibc-9ce3b2cbd245abedc6cff147a1b91566e340edb1.tar.bz2
BZ#15380: Fix initstate error return
[BZ #15380] * stdlib/random.c (__initstate): Return NULL if __initstate fails.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/random.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/stdlib/random.c b/stdlib/random.c
index 3ed610d..967dec3 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)