From 71644cc98b27d65cabb307530a9f947923139a76 Mon Sep 17 00:00:00 2001 From: KJeff01 Date: Wed, 21 Feb 2024 15:07:24 -0600 Subject: [PATCH 1/3] Check for nullptr on object in orderDroidObj() --- src/order.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/order.cpp b/src/order.cpp index 1bc1fd8dd02..0c7afcf43e5 100644 --- a/src/order.cpp +++ b/src/order.cpp @@ -2037,6 +2037,7 @@ void orderDroidObj(DROID *psDroid, DROID_ORDER order, BASE_OBJECT *psObj, QUEUE_ { ASSERT(psDroid != nullptr, "Invalid unit pointer"); ASSERT(validOrderForObj(order), "Invalid order for object"); + ASSERT_OR_RETURN(, psObj != nullptr, "Invalid object pointer"); ASSERT_OR_RETURN(, !isBlueprint(psObj), "Target %s is a blueprint", objInfo(psObj)); ASSERT_OR_RETURN(, !psObj->died, "Target dead"); From 90580d3ed09afd7c007eaeb4b8d43f5c254b4788 Mon Sep 17 00:00:00 2001 From: KJeff01 Date: Mon, 26 Feb 2024 19:30:33 -0600 Subject: [PATCH 2/3] Prevent crash if IMD is bad for renderExplosionEffect() --- src/effects.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/effects.cpp b/src/effects.cpp index 9efe9b46db3..776ee717477 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1534,6 +1534,11 @@ static void renderExplosionEffect(const EFFECT *psEffect, const glm::mat4 &viewM { const PIELIGHT brightness = WZCOL_WHITE; + if (psEffect == nullptr || psEffect->imd == nullptr) + { + return; + } + if (psEffect->type == EXPLOSION_TYPE_LAND_LIGHT) { if (rejectLandLight((LAND_LIGHT_SPEC)psEffect->specific)) From 35ecfff59bdcbae6307b258105366333ecc279fb Mon Sep 17 00:00:00 2001 From: KJeff01 Date: Mon, 26 Feb 2024 19:41:41 -0600 Subject: [PATCH 3/3] Prevent crash in doWaveTerrain() --- src/visibility.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/visibility.cpp b/src/visibility.cpp index f5439ce7489..a5143f7ce39 100644 --- a/src/visibility.cpp +++ b/src/visibility.cpp @@ -256,9 +256,14 @@ static inline void visMarkTile(const BASE_OBJECT *psObj, int mapX, int mapY, MAP /* The terrain revealing ray callback */ static void doWaveTerrain(BASE_OBJECT *psObj) { + if (psObj == nullptr) + { + return; + } + const int sx = psObj->pos.x; const int sy = psObj->pos.y; - const int sz = psObj->pos.z + MAX(MIN_VIS_HEIGHT, psObj->sDisplay.imd->max.y); + const int sz = psObj->pos.z + ((psObj->sDisplay.imd != nullptr) ? MAX(MIN_VIS_HEIGHT, psObj->sDisplay.imd->max.y) : MIN_VIS_HEIGHT); const unsigned radius = objSensorRange(psObj); const int rayPlayer = psObj->player; size_t size;