Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adélie Linux
gcompat
Commits
8af2ff25
Commit
8af2ff25
authored
Dec 19, 2021
by
A. Wilcox
🦊
Browse files
random_r: set `x` before calling savestate_r
Prevents segfault when calling initstate_r.
parent
2b502554
Changes
1
Hide whitespace changes
Inline
Side-by-side
libgcompat/random_r.c
View file @
8af2ff25
...
...
@@ -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
;
...
...
Patrycja Rosa
@ptrcnull
mentioned in issue
#344 (closed)
·
Jan 01, 2022
mentioned in issue
#344 (closed)
mentioned in issue #344
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment