Commit 490be60
authored
Fix undefined behavior when initializing
While working on implementing a safe abstraction around `cpu_set_t` for the `rsix` crate I've find you're usage of `cpu_set_t`.
However you're usage of it is instant UB because you initialize them when `MaybeUninit::uninit().assume_init()` which is UB by definition.
Comment from bjorn3:
> With UB anything is allowed including compiling it correctly. A future compiler version may replace MaybeUninit::uninit().assume_init() with intrinsics::unreachable(), which makes the syscall trivially unreachable.
Replace their usage with `std::mem::zeroed` witch is the same as using `CPU_ZERO` after initilization.cpu_set_t
1 parent 03b0d5a commit 490be60
1 file changed
+3
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
8 | 7 | | |
9 | | - | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
| |||
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 24 | + | |
29 | 25 | | |
30 | 26 | | |
31 | 27 | | |
| |||
0 commit comments