summaryrefslogtreecommitdiff
path: root/libgcompat
diff options
context:
space:
mode:
authorA. Wilcox <awilcox@wilcox-tech.com>2021-12-19 22:46:41 +0000
committerA. Wilcox <awilcox@wilcox-tech.com>2021-12-19 22:46:41 +0000
commit8af2ff25620082c5fe275f1fd0d20b0a52dca0c0 (patch)
treef908d59252927ab00ea70c356c463c2b52e2a1ae /libgcompat
parent2b502554bad0871b71e41d03a870771fe9257fce (diff)
downloadgcompat-8af2ff25620082c5fe275f1fd0d20b0a52dca0c0.tar.gz
gcompat-8af2ff25620082c5fe275f1fd0d20b0a52dca0c0.tar.bz2
gcompat-8af2ff25620082c5fe275f1fd0d20b0a52dca0c0.tar.xz
gcompat-8af2ff25620082c5fe275f1fd0d20b0a52dca0c0.zip
random_r: set `x` before calling savestate_r
Prevents segfault when calling initstate_r.
Diffstat (limited to 'libgcompat')
-rw-r--r--libgcompat/random_r.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libgcompat/random_r.c b/libgcompat/random_r.c
index 5bc7053..daa23e7 100644
--- a/libgcompat/random_r.c
+++ b/libgcompat/random_r.c
@@ -103,6 +103,7 @@ int initstate_r(unsigned seed, char *restrict state, size_t size,
return -1;
}
+ buf->x = (int32_t*)state + 1;
savestate_r(buf);
if (size < 32) {
buf->n = 0;
@@ -115,7 +116,6 @@ int initstate_r(unsigned seed, char *restrict state, size_t size,
} else {
buf->n = 63;
}
- buf->x = (int32_t*)state + 1;
srandom_r(seed, buf);
savestate_r(buf);
return 0;