Merge branch 'fix-pointtodist-negative-abs' into 'next'

Fix crash in R_PointToDist2 when passing -2147483648

See merge request STJr/SRB2!1964
This commit is contained in:
Logan Aerl Arias 2023-12-25 23:58:03 +00:00
commit 03626bccfe
2 changed files with 3 additions and 2 deletions

View file

@ -34,6 +34,7 @@
*/
typedef INT32 fixed_t;
typedef UINT32 ufixed_t;
/*!
\brief convert fixed_t into floating number
@ -106,7 +107,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedInt(fixed_t a)
*/
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b)
{
if ((abs(a) >> (FRACBITS-2)) >= abs(b))
if (((ufixed_t)abs(a) >> (FRACBITS-2)) >= (ufixed_t)abs(b))
return (a^b) < 0 ? INT32_MIN : INT32_MAX;
return FixedDiv2(a, b);

View file

@ -356,7 +356,7 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y)
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1)
{
angle_t angle;
fixed_t dx, dy, dist;
ufixed_t dx, dy, dist;
dx = abs(px1 - px2);
dy = abs(py1 - py2);