mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
std: Make atfork handler more robust
The atfork handler is executed even when fork()-ing threads that have never initialized their local csprng. Handle this case gracefully instead of raising a runtime error. Fixes #8841
This commit is contained in:
parent
abfe7f96dd
commit
ec9a44b2a5
@ -150,6 +150,9 @@ fn setupPthreadAtforkAndFill(buffer: []u8) void {
|
||||
}
|
||||
|
||||
fn childAtForkHandler() callconv(.C) void {
|
||||
// The atfork handler is global, this function may be called after
|
||||
// fork()-ing threads that never initialized the CSPRNG context.
|
||||
if (wipe_mem.len == 0) return;
|
||||
std.crypto.utils.secureZero(u8, wipe_mem);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user