Skip to content

Commit

Permalink
Fix potential FixedDiv overflow when passed INT_MIN as first arg
Browse files Browse the repository at this point in the history
  • Loading branch information
gendlin committed Aug 11, 2024
1 parent 2cad60b commit e49af75
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/m_fixed.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ inline static int64_t FixedMul64(int64_t a, int64_t b)
inline static fixed_t FixedDiv(fixed_t a, fixed_t b)
{
// [FG] avoid 31-bit shift (from Chocolate Doom)
if ((abs(a) >> 14) >= abs(b))
if (((unsigned)abs(a) >> 14) >= (unsigned)abs(b))
{
return (a ^ b) < 0 ? INT_MIN : INT_MAX;
}
Expand Down

0 comments on commit e49af75

Please sign in to comment.