From 0030367649004f53c977f0ee5fa85fac8bf200c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Oct 2025 14:08:17 +0200 Subject: [PATCH] fix UB in R_PointOnSide by not shifting a 32bit int by 31 bits this is more in line with the original function eitherways --- src/r_main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.h b/src/r_main.h index 4ec43a2f3..850101e64 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -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))); }