fix UB in R_PointOnSide

by not shifting a 32bit int by 31 bits
this is more in line with the original function eitherways
This commit is contained in:
Alug committed 2025-10-16 14:08:30 +02:00
1 parent 66f67c91e8
commit 0030367649
1 file changed
+1 -1
+1 -1
View File
@@ -97,7 +97,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y,
// Try to quickly decide by looking at sign bits.
// also use a mask to avoid branch prediction
INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31;
INT32 mask = (((node->dy ^ node->dx ^ x ^ y) < 0) ? -1 : 0);
return (mask & ((node->dy ^ x) < 0)) | // (left is negative)
(~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x)));
}