From 666d8c82df144bb56f0a34dc4880d5046f5886a2 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 25 Jan 2024 19:04:48 +0700 Subject: [PATCH] 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 --- rehlds/engine/common.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/common.cpp b/rehlds/engine/common.cpp index e70d03ca..c9740a28 100644 --- a/rehlds/engine/common.cpp +++ b/rehlds/engine/common.cpp @@ -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 22 bits precision\n", __func__); } uint32 shift = (1 << numbits);