Skip to content

Commit

Permalink
MSG_WriteBitAngle: Cap the precision check from 32 to 22 to avoid ove…
Browse files Browse the repository at this point in the history
…rflow issues when representing angles with more than 22 bits because the multiply by 'shift' may result in overflow
  • Loading branch information
s1lentq committed Jan 26, 2024
1 parent 9b0dbe8 commit 63fde22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rehlds/engine/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ void MSG_WriteBitData(void *src, int length)

void MSG_WriteBitAngle(float fAngle, int numbits)
{
if (numbits >= 32)
if (numbits > 22)
{
Sys_Error("%s: Can't write bit angle with 32 bits precision\n", __func__);
Sys_Error("%s: Can't write bit angle with more than 22 bits precision\n", __func__);
}

uint32 shift = (1 << numbits);
Expand Down

0 comments on commit 63fde22

Please sign in to comment.