]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Q3BSP: fix UB when loading certain maps
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 5 May 2024 14:14:52 +0000 (00:14 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 9 May 2024 03:07:35 +0000 (13:07 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
model_brush.c

index 19c17a40751d84e8a3ed358c50139f9f4544fdcb..35d12f002acaa0a62e61ea20d1c1a16c102ccb0b 100644 (file)
@@ -6360,8 +6360,9 @@ static void Mod_Q3BSP_LoadLeafs(lump_t *l)
                for (j = 0;j < 3;j++)
                {
                        // yes the mins/maxs are ints
-                       out->mins[j] = LittleLong(in->mins[j]) - 1;
-                       out->maxs[j] = LittleLong(in->maxs[j]) + 1;
+                       // bones_was_here: the cast prevents signed underflow with poon-wood.bsp
+                       out->mins[j] = (vec_t)LittleLong(in->mins[j]) - 1;
+                       out->maxs[j] = (vec_t)LittleLong(in->maxs[j]) + 1;
                }
                n = LittleLong(in->firstleafface);
                c = LittleLong(in->numleaffaces);