2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-27 07:05:43 +03:00

MSG_WriteBitAngle: Cap the precision check from 32 to 22 to avoid overflow issues when representing angles with more than 22 bits because the multiply by 'shift' may result in overflow

This commit is contained in:
s1lentq 2024-01-25 19:04:48 +07:00
parent 9b0dbe8dd2
commit 63fde229c9

View File

@ -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);