Skip to content

Commit

Permalink
vertexcodec: Fix UBSAN violation
Browse files Browse the repository at this point in the history
Shift right by 32 is technically UB; in practice it should not matter
because two valid HW behaviors would either keep v as is, or return 0,
and both result in the same final output, but we should fix this
regardless.
  • Loading branch information
zeux committed Dec 18, 2024
1 parent 62a3197 commit c4d1d42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/vertexcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ inline unsigned int zigzag(unsigned int v)

inline unsigned int rotate(unsigned int v, int r)
{
return (v << r) | (v >> (32 - r));
return (v << r) | (v >> ((32 - r) & 31));
}

template <typename T>
Expand Down

0 comments on commit c4d1d42

Please sign in to comment.