From b4107ce30d96ca450a845e88f356c6028823ab44 Mon Sep 17 00:00:00 2001 From: ip_gpu Date: Mon, 30 Oct 2017 15:23:28 +0500 Subject: [PATCH] fixed from PVS-Studio: V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] modFileName;'. log.cpp 374 V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] modFileName;'. log.cpp 379 V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] buff;'. log.cpp 416 V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] searchPath;'. stdafx.cpp 108 V611 The memory was allocated using 'new T[]' operator but was released using the 'delete' operator. Consider inspecting this code. It's probably better to use 'delete [] searchPath;'. stdafx.cpp 120 V668 There is no sense in testing the 'buff' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. log.cpp 416 --- Log.cpp | 6 +++--- stdafx.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Log.cpp b/Log.cpp index dc90f47..f9c6db5 100644 --- a/Log.cpp +++ b/Log.cpp @@ -371,12 +371,12 @@ bool CVersionInfo::GetModuleVersionInfo(HMODULE hMod) { modFileName = new TCHAR[MAX_PATH]; retVal = GetModuleFileName(hMod, modFileName, MAX_PATH); if (!retVal) { - delete modFileName; + delete[] modFileName; ::WriteToLog(L"CLog::GetModuleVersion - Error while getting module filename..."); return false; } retVal = GetModuleVersionInfo(modFileName); - delete modFileName; + delete[] modFileName; return (retVal == TRUE); } @@ -413,7 +413,7 @@ bool CVersionInfo::GetModuleVersionInfo(LPTSTR modName = NULL) { if (retVal) this->g_bVerInfoBuff = buff; else - if (buff) delete buff; + delete[] buff; return (retVal == TRUE); } diff --git a/stdafx.cpp b/stdafx.cpp index 1b2c84b..1122223 100644 --- a/stdafx.cpp +++ b/stdafx.cpp @@ -105,7 +105,7 @@ bool FileExists(LPTSTR fileName) { h = FindFirstFile(searchPath, &wfData); if (colonPtr) colonPtr[0] = ':'; if (h != INVALID_HANDLE_VALUE) { - delete searchPath; + delete[] searchPath; FindClose(h); return true; } @@ -117,7 +117,7 @@ bool FileExists(LPTSTR fileName) { } wcscat_s(searchPath, strMaxSize, L"*.*"); h = FindFirstFile(searchPath, &wfData); - delete searchPath; + delete[] searchPath; if (h != INVALID_HANDLE_VALUE) { FindClose(h); return true;