From ca70de93a45b724268c5ca4bedddddc4fd20b276 Mon Sep 17 00:00:00 2001 From: Viktor Andreev Date: Mon, 28 Oct 2024 15:09:37 +0600 Subject: [PATCH] Removed memory leak --- Common/OfficeFileFormatChecker2.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index ec8a16a627..e6a3b0331c 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -740,13 +740,33 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName) if (OfficeUtils.IsArchive(fileName) == S_OK && (false == isPdfFormatFile(bufferDetect, dwDetectdBytes, sDocumentID))) { if (isOOXFormatFile(fileName)) + { + if (bufferDetect) + delete[] bufferDetect; + bufferDetect = NULL; return true; + } else if (isOpenOfficeFormatFile(fileName, sDocumentID)) - return true; + { + if (bufferDetect) + delete[] bufferDetect; + bufferDetect = NULL; + return true; + } else if (isOnlyOfficeFormatFile(fileName)) - return true; + { + if (bufferDetect) + delete[] bufferDetect; + bufferDetect = NULL; + return true; + } else if (isXpsFile(fileName)) - return true; + { + if (bufferDetect) + delete[] bufferDetect; + bufferDetect = NULL; + return true; + } } //-----------------------------------------------------------------------------------------------