From 2c5b7fee351269390407ab69e5b8005bedc2d05b Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:38:12 +0400 Subject: [PATCH 1/2] Fix code scanning alert no. 98: Potential use after free Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- tiberiandawn/terrain.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tiberiandawn/terrain.cpp b/tiberiandawn/terrain.cpp index 2593e398..382b6d63 100644 --- a/tiberiandawn/terrain.cpp +++ b/tiberiandawn/terrain.cpp @@ -537,6 +537,7 @@ void TerrainClass::AI(void) */ if (IsCrumbling && Fetch_Stage() == Get_Build_Frame_Count(Class->Get_Image_Data()) - 1) { delete this; + return; } } From 31771e5856a78c0cc8a6396d39ad94b44d2c61fd Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Tue, 5 Nov 2024 21:39:12 +0400 Subject: [PATCH 2/2] Fix code scanning alert no. 96: Potential use after free Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- redalert/unit.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/redalert/unit.cpp b/redalert/unit.cpp index 06762f51..37eb0a28 100644 --- a/redalert/unit.cpp +++ b/redalert/unit.cpp @@ -4400,8 +4400,10 @@ BulletClass* UnitClass::Fire_At(TARGET target, int which) if (bullet != NULL) { #ifdef FIXIT_CSII // checked - ajw 9/28/98 - if (Class->Type == UNIT_DEMOTRUCK && IsActive) + if (Class->Type == UNIT_DEMOTRUCK && IsActive) { delete this; + return NULL; + } #endif /* ** Possible reload timer set.