From dafaae65fb4bf5732ebf2d82b034dd2a30262031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Mon, 7 Oct 2024 21:24:37 +0200 Subject: [PATCH] Avoid dereferencing thing before assertion checks --- src/p_map.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 98a85e614..c1e73e9f8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2021,7 +2021,7 @@ static boolean PIT_CheckLine(line_t *ld) boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { INT32 xl, xh, yl, yh, bx, by; - subsector_t *newsubsec = thing->subsector; + subsector_t *newsubsec; boolean blockval = true; ps_checkposition_calls.value.i++; @@ -2045,6 +2045,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) if (thing->x != x || thing->y != y) newsubsec = R_PointInSubsector(x, y); + else + newsubsec = thing->subsector; ceilingline = blockingline = NULL; // The base floor / ceiling is from the subsector