aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-10 17:07:03 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-10 17:07:03 +0000
commit26afaa635796fee008c09155865ee3886bced9c4 (patch)
treed0495d7fef0a72aff572f56985a6c2792e4bb912 /stdlib
parent6c79e60c344f6b45f36f3e8ba7458af96326ffc4 (diff)
downloadglibc-26afaa635796fee008c09155865ee3886bced9c4.zip
glibc-26afaa635796fee008c09155865ee3886bced9c4.tar.gz
glibc-26afaa635796fee008c09155865ee3886bced9c4.tar.bz2
Update.
* stdlib/random_r.c (__setstate_r): Allow call with same state array as currently used (PR libc/774).
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/random_r.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/stdlib/random_r.c b/stdlib/random_r.c
index 918bd69..445bc95 100644
--- a/stdlib/random_r.c
+++ b/stdlib/random_r.c
@@ -268,13 +268,13 @@ __setstate_r (arg_state, buf)
struct random_data *buf;
{
int32_t *new_state = (int32_t *) arg_state;
- int type = new_state[0] % MAX_TYPES;
+ int type;
int old_type;
int32_t *old_state;
int degree;
int separation;
- if (buf == NULL || type < TYPE_0 || type >= TYPE_4)
+ if (buf == NULL)
goto fail;
old_type = buf->rand_type;
@@ -284,6 +284,10 @@ __setstate_r (arg_state, buf)
else
old_state[-1] = (MAX_TYPES * (buf->rptr - old_state)) + old_type;
+ type = new_state[0] % MAX_TYPES;
+ if (type < TYPE_0 || type >= TYPE_4)
+ goto fail;
+
buf->rand_deg = degree = random_poly_info.degrees[type];
buf->rand_sep = separation = random_poly_info.seps[type];
buf->rand_type = type;