From 6cb2e6864142afffb82e964bc31af16e48a86ba9 Mon Sep 17 00:00:00 2001 From: ip_gpu Date: Mon, 30 Oct 2017 23:02:01 +0500 Subject: [PATCH] fixed from PVS-Studio: V575 The number of processed elements should be passed to the 'GetWindowTextW' function as the third argument instead of buffer's size in bytes. urlctrl.cpp 166, 214 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 [] pBuffer;'. plugindefinition.cpp 133, 154 --- src/PluginDefinition.cpp | 4 ++-- src/URLCtrl.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PluginDefinition.cpp b/src/PluginDefinition.cpp index f43e069..d3e92c6 100644 --- a/src/PluginDefinition.cpp +++ b/src/PluginDefinition.cpp @@ -130,7 +130,7 @@ DWORD WINAPI ThreadProc(LPVOID lpParameter){ delete result; } - delete pBuffer; + delete[] pBuffer; } else{ @@ -151,7 +151,7 @@ DWORD WINAPI ThreadProc(LPVOID lpParameter){ delete result; } - delete pBuffer; + delete[] pBuffer; } return 0; } diff --git a/src/URLCtrl.cpp b/src/URLCtrl.cpp index da70800..45475ad 100644 --- a/src/URLCtrl.cpp +++ b/src/URLCtrl.cpp @@ -163,7 +163,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) // Draw the text! TCHAR szWinText[_MAX_PATH]; - ::GetWindowText(hwnd, szWinText, sizeof szWinText); + ::GetWindowText(hwnd, szWinText, sizeof szWinText / sizeof TCHAR); ::DrawText(hdc, szWinText, -1, &rect, dwDTStyle); ::SelectObject(hdc, hOld); @@ -211,7 +211,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) else { TCHAR szWinText[_MAX_PATH]; - ::GetWindowText(hwnd, szWinText, sizeof szWinText); + ::GetWindowText(hwnd, szWinText, sizeof szWinText / sizeof TCHAR); ::ShellExecute(NULL, _T("open"), szWinText, NULL, NULL, SW_SHOWNORMAL); } }