From 2c9a82e084c23a36f0c7c86bd6367077801219a6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 7 Oct 2018 19:59:51 +0200 Subject: [PATCH] - fixed potential null pointer access in Hexen's spike code. --- wadsrc/static/zscript/hexen/spike.txt | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/wadsrc/static/zscript/hexen/spike.txt b/wadsrc/static/zscript/hexen/spike.txt index cb8df17e27..a411dbf3f6 100644 --- a/wadsrc/static/zscript/hexen/spike.txt +++ b/wadsrc/static/zscript/hexen/spike.txt @@ -179,26 +179,29 @@ class ThrustFloor : Actor while (it.Next()) { let targ = it.thing; - double blockdist = radius + it.thing.radius; - if (abs(targ.pos.x - it.Position.X) >= blockdist || abs(targ.pos.y - it.Position.Y) >= blockdist) - continue; - - // Q: Make this z-aware for everything? It never was before. - if (targ.pos.z + targ.height < pos.z || targ.pos.z > pos.z + height) + if (targ != null) { - if (CurSector.PortalGroup != targ.CurSector.PortalGroup) + double blockdist = radius + targ.radius; + if (abs(targ.pos.x - it.Position.X) >= blockdist || abs(targ.pos.y - it.Position.Y) >= blockdist) continue; + + // Q: Make this z-aware for everything? It never was before. + if (targ.pos.z + targ.height < pos.z || targ.pos.z > pos.z + height) + { + if (CurSector.PortalGroup != targ.CurSector.PortalGroup) + continue; + } + + if (!targ.bShootable) + continue; + + if (targ == self) + continue; // don't clip against self + + int newdam = targ.DamageMobj (self, self, 10001, 'Crush'); + targ.TraceBleed (newdam > 0 ? newdam : 10001, null); + args[1] = 1; // Mark thrust thing as bloody } - - if (!targ.bShootable) - continue; - - if (targ == self) - continue; // don't clip against self - - int newdam = targ.DamageMobj (self, self, 10001, 'Crush'); - targ.TraceBleed (newdam > 0 ? newdam : 10001, null); - args[1] = 1; // Mark thrust thing as bloody } } }