Skip to content
Snippets Groups Projects
Commit e50672cf authored by Arseny Kapoulkine's avatar Arseny Kapoulkine
Browse files

ubsan: Fix undefined behavior for signed left shift in compact mode

We were using << compact_alignment_log2 instead of * compact_alignment
for symmetry with the encoding where >> is crucial to keep code fast and
round to negative infinity.

For decoding, the results are the same and any reasonable compiler
should convert *4 into <<2 so just use a multiplication - that doesn't
trigger UB on negative numbers.
parent 9540016f
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment