Commit 0693988
authored
Fix unaligned memory access UB in compact_vector::access() (#11)
* Fix unaligned memory access UB in compact_vector::access()
Replace reinterpret_cast + dereference with memcpy to avoid undefined
behavior when accessing unaligned uint64_t values. This fixes crashes
and incorrect behavior on ARM64 where unaligned access is not tolerated.
The memcpy approach is standards-compliant and compilers optimize it to
efficient code on all platforms.
* fix UB in append_bits
* Fix assert1 parent 361ee92 commit 0693988
2 files changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
253 | 254 | | |
254 | 255 | | |
255 | 256 | | |
256 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
| |||
0 commit comments