diff --git a/plugins/check_disk.cpp b/plugins/check_disk.cpp index c81a4e61f..b8a968f05 100644 --- a/plugins/check_disk.cpp +++ b/plugins/check_disk.cpp @@ -275,13 +275,13 @@ int check_drives(vector& vDrives) while (GetLastError() != ERROR_NO_MORE_FILES) { volumeNameEnd = wcslen(szVolumeName) - 1; - szVolumePathNames = (PWCHAR) new BYTE[dwVolumePathNamesLen * sizeof(wchar_t)]; + szVolumePathNames = reinterpret_cast(new WCHAR[dwVolumePathNamesLen]); while (!GetVolumePathNamesForVolumeName(szVolumeName, szVolumePathNames, dwVolumePathNamesLen, &dwVolumePathNamesLen)) { if (GetLastError() != ERROR_MORE_DATA) break; - delete[] szVolumePathNames; - szVolumePathNames = (PWCHAR) new BYTE[dwVolumePathNamesLen * sizeof(wchar_t)]; + delete[] reinterpret_cast(szVolumePathNames); + szVolumePathNames = reinterpret_cast(new WCHAR[dwVolumePathNamesLen]); } diff --git a/plugins/check_network.cpp b/plugins/check_network.cpp index 326ecc9af..688f78fbc 100644 --- a/plugins/check_network.cpp +++ b/plugins/check_network.cpp @@ -239,13 +239,13 @@ int check_network(vector & vInterfaces) err = PdhGetFormattedCounterArray(phCounterIn, PDH_FMT_LONG, &dwBufferSizeIn, &dwItemCount, pDisplayValuesIn); if (err == PDH_MORE_DATA || SUCCEEDED(err)) - pDisplayValuesIn = new PDH_FMT_COUNTERVALUE_ITEM[dwItemCount*dwBufferSizeIn]; + pDisplayValuesIn = reinterpret_cast(new BYTE[dwItemCount*dwBufferSizeIn]); else goto die; err = PdhGetFormattedCounterArray(phCounterOut, PDH_FMT_LONG, &dwBufferSizeOut, &dwItemCount, pDisplayValuesOut); if (err == PDH_MORE_DATA || SUCCEEDED(err)) - pDisplayValuesOut = new PDH_FMT_COUNTERVALUE_ITEM[dwItemCount*dwBufferSizeOut]; + pDisplayValuesOut = reinterpret_cast(new BYTE[dwItemCount*dwBufferSizeIn]); else goto die; @@ -272,8 +272,8 @@ die: if (phQuery) PdhCloseQuery(phQuery); if (pDisplayValuesIn) - delete pDisplayValuesIn; + delete reinterpret_cast(pDisplayValuesIn); if (pDisplayValuesOut) - delete pDisplayValuesOut; + delete reinterpret_cast(pDisplayValuesOut); return 3; } \ No newline at end of file diff --git a/plugins/check_procs.cpp b/plugins/check_procs.cpp index da47e1b46..942c027db 100644 --- a/plugins/check_procs.cpp +++ b/plugins/check_procs.cpp @@ -256,7 +256,7 @@ int countProcs(const wstring user) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue; - pSIDTokenUser = (PTOKEN_USER)new BYTE[dwReturnLength]; + pSIDTokenUser = reinterpret_cast(new BYTE[dwReturnLength]); memset(pSIDTokenUser, 0, dwReturnLength); if (!pSIDTokenUser) @@ -276,8 +276,8 @@ int countProcs(const wstring user) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) continue; - AcctName = (LPWSTR) new wchar_t[dwAcctName]; - DomainName = (LPWSTR) new wchar_t[dwDomainName]; + AcctName = reinterpret_cast(new WCHAR[dwAcctName]); + DomainName = reinterpret_cast(new WCHAR[dwDomainName]); if (!AcctName || !DomainName) continue; @@ -289,6 +289,8 @@ int countProcs(const wstring user) if (!wcscmp(AcctName, wuser)) ++numProcs; + delete[] reinterpret_cast(AcctName); + delete[] reinterpret_cast(DomainName); } while (Process32Next(hProcessSnap, &pe32)); @@ -300,5 +302,7 @@ die: CloseHandle(hProcess); if (hToken) CloseHandle(hToken); + if (pSIDTokenUser) + delete[] reinterpret_cast(pSIDTokenUser); return numProcs; } \ No newline at end of file diff --git a/plugins/check_service.cpp b/plugins/check_service.cpp index 885e14442..b55045420 100644 --- a/plugins/check_service.cpp +++ b/plugins/check_service.cpp @@ -178,7 +178,7 @@ int ServiceStatus(const printInfoStruct& printInfo) && GetLastError() != ERROR_MORE_DATA) goto die; - lpServices = new BYTE[*pcbBytesNeeded]; + lpServices = reinterpret_cast(new BYTE[*pcbBytesNeeded]); cbBufSize = *pcbBytesNeeded; if (!EnumServicesStatusEx(service_api, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_STATE_ALL, @@ -196,7 +196,7 @@ int ServiceStatus(const printInfoStruct& printInfo) die: if (lpServices) - delete lpServices; + delete[] reinterpret_cast(lpServices); wcout << L"Service " << printInfo.service << L" could not be found" << endl; return -1; }