From 1672fd89014038d53b1f302b6907de5bfda3550d Mon Sep 17 00:00:00 2001 From: Zero Fanker Date: Sun, 20 Oct 2024 16:14:56 -0400 Subject: [PATCH] a potential double free fix . --- MissionEditor/Loading.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MissionEditor/Loading.cpp b/MissionEditor/Loading.cpp index 503a263..50c3478 100644 --- a/MissionEditor/Loading.cpp +++ b/MissionEditor/Loading.cpp @@ -1934,11 +1934,11 @@ void CLoading::SetImageData(unsigned char* pBuffer, const CString& NameInDict, i void CLoading::SetImageData(unsigned char* pBuffer, PICDATA& pData, const int FullWidth, const int FullHeight, Palette* pPal, bool forceNoRemap) { - if (pData.pic) { - delete[](pData.pic); + if (auto pPic = std::exchange(pData.pic, nullptr)) { + delete[](pPic); } - if (pData.vborder) { - delete[](pData.vborder); + if (auto pBorder = std::exchange(pData.vborder, nullptr)) { + delete[](pBorder); } // Get available area