Skip to content

Commit 4e38aa4

Browse files
committed
initialize variables
1 parent 4f1e45d commit 4e38aa4

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/MainDlg.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ bool CMainDlg::DoMouseUp(UINT /*message*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
299299
if (hwndTemp == *this)
300300
return false;
301301

302-
TCHAR szText[256];
302+
TCHAR szText[256]{};
303303
_stprintf_s(szText, _countof(szText), _T("0x%p"), m_hwndFoundWindow);
304304
SetDlgItemText(*this, IDC_WINDOW, szText);
305305

@@ -428,7 +428,7 @@ bool CMainDlg::SendPostMessage(UINT id)
428428
UINT msg = 0;
429429
WPARAM wparam = 0;
430430
LPARAM lparam = 0;
431-
TCHAR buf[MAX_PATH];
431+
TCHAR buf[MAX_PATH]{};
432432
TCHAR* endptr = nullptr;
433433

434434
::GetDlgItemText(*this, IDC_MESSAGE, buf, _countof(buf));
@@ -500,7 +500,7 @@ bool CMainDlg::SendPostMessage(UINT id)
500500
0,
501501
nullptr))
502502
{
503-
lpDisplayBuf = LocalAlloc(LMEM_ZEROINIT, (lstrlen(static_cast<LPCTSTR>(lpMsgBuf)) + 40) * sizeof(TCHAR));
503+
lpDisplayBuf = LocalAlloc(LMEM_ZEROINIT, (lstrlen(static_cast<LPCTSTR>(lpMsgBuf)) + 40LL) * sizeof(TCHAR));
504504
if (lpDisplayBuf)
505505
{
506506
_stprintf_s(static_cast<LPTSTR>(lpDisplayBuf), LocalSize(lpDisplayBuf) / sizeof(TCHAR), _T("error %lu: %s"), err, (LPTSTR)lpMsgBuf);

src/SendMessage.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <Psapi.h>
3030

3131
// Global Variables:
32-
HINSTANCE hInst; // current instance
32+
HINSTANCE hInst = nullptr; // current instance
3333
std::wstring windowTitle;
3434
std::wstring windowClass;
3535
std::wstring windowAccessiblename;
@@ -95,7 +95,7 @@ BOOL CALLBACK WindowEnumerator(HWND hwnd, LPARAM lParam)
9595
bool bMatches = true;
9696
if (!windowTitle.empty())
9797
{
98-
TCHAR buf[4096];
98+
TCHAR buf[4096]{};
9999
GetWindowText(hwnd, buf, _countof(buf));
100100
if (windowTitle.substr(0, 4096).compare(buf) != 0)
101101
bMatches = false;
@@ -163,7 +163,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
163163
::OleInitialize(nullptr);
164164
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
165165
// we need some of the common controls
166-
INITCOMMONCONTROLSEX icex;
166+
INITCOMMONCONTROLSEX icex{};
167167
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
168168
icex.dwICC = ICC_LINK_CLASS | ICC_LISTVIEW_CLASSES | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS | ICC_STANDARD_CLASSES | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES | ICC_WIN95_CLASSES;
169169
InitCommonControlsEx(&icex);

src/WindowTreeDlg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ BOOL CWindowTreeDlg::WindowEnumerator(HWND hwnd, LPARAM lParam)
125125
{
126126
auto* pThis = reinterpret_cast<CWindowTreeDlg*>(lParam);
127127

128-
TCHAR buf[4096];
128+
TCHAR buf[4096]{};
129129
GetWindowString(hwnd, buf, _countof(buf));
130130

131-
TCHAR filter[MAX_PATH];
131+
TCHAR filter[MAX_PATH]{};
132132
::GetDlgItemText(*pThis, IDC_FILTER, filter, _countof(filter));
133133
if (filter[0] == '\0' || StrStrI(buf, filter) != nullptr)
134134
{
@@ -149,10 +149,10 @@ BOOL CWindowTreeDlg::ChildWindowEnumerator(HWND hwnd, LPARAM lParam)
149149
{
150150
auto* pThis = reinterpret_cast<CWindowTreeDlg*>(lParam);
151151

152-
TCHAR buf[4096];
152+
TCHAR buf[4096]{};
153153
GetWindowString(hwnd, buf, _countof(buf));
154154

155-
TCHAR filter[MAX_PATH];
155+
TCHAR filter[MAX_PATH]{};
156156
::GetDlgItemText(*pThis, IDC_FILTER, filter, _countof(filter));
157157
if (filter[0] == '\0' || StrStrI(buf, filter) != nullptr)
158158
{

0 commit comments

Comments
 (0)