From 5281e2d3b9adea8dff1730d78fe94af85582aea8 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 9 Jul 2014 05:32:14 +0200 Subject: Static Code Analysis : fix resource leakage by ensuring that all Windows handles are released properly --- src/Mount/Mount.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/Mount') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 370c5f57..eee282a8 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -7001,7 +7001,11 @@ BOOL TaskBarIconAdd (HWND hwnd) TaskBarIconMutex = CreateMutex (NULL, TRUE, "VeraCryptTaskBarIcon"); if (TaskBarIconMutex == NULL || GetLastError () == ERROR_ALREADY_EXISTS) { - TaskBarIconMutex = NULL; + if (TaskBarIconMutex) + { + CloseHandle(TaskBarIconMutex); + TaskBarIconMutex = NULL; + } return FALSE; } @@ -8692,7 +8696,12 @@ void AnalyzeKernelMiniDump (HWND hwndDlg) NormalCursor(); DWORD exitCode; - if (!GetExitCodeProcess (procInfo.hProcess, &exitCode) || exitCode != 0) + bool bExitCheck = (!GetExitCodeProcess (procInfo.hProcess, &exitCode) || exitCode != 0); + + CloseHandle(procInfo.hProcess); + CloseHandle(procInfo.hThread); + + if (bExitCheck) return; } @@ -8764,6 +8773,10 @@ void AnalyzeKernelMiniDump (HWND hwndDlg) { handleWin32Error (hwndDlg); Error ("DEBUGGER_NOT_FOUND"); + CloseHandle (procInfo.hProcess); + CloseHandle (procInfo.hThread); + CloseHandle (hChildStdoutRead); + CloseHandle (hChildStdoutWrite); return; } @@ -8787,6 +8800,8 @@ void AnalyzeKernelMiniDump (HWND hwndDlg) output.insert (output.size(), pipeBuffer, bytesReceived); } + CloseHandle (hChildStdoutRead); + NormalCursor(); bool otherDriver = (StringToUpperCase (output).find (StringToUpperCase (TC_APP_NAME)) == string::npos); @@ -8868,7 +8883,7 @@ void AnalyzeKernelMiniDump (HWND hwndDlg) retAddrs.push_back (s); } - /* +/* char url[MAX_URL_LENGTH]; sprintf (url, TC_APPLINK_SECURE "&dest=syserr-report&os=%s&osver=%d.%d.%d&arch=%s&err=%I64x&arg1=%I64x&arg2=%I64x&arg3=%I64x&arg4=%I64x&flag=%s&drv=%s", GetWindowsEdition().c_str(), @@ -8943,7 +8958,7 @@ void AnalyzeKernelMiniDump (HWND hwndDlg) if (AskYesNoString (msg.c_str()) == IDYES) ShellExecute (NULL, "open", urlStr.c_str(), NULL, NULL, SW_SHOWNORMAL); - */ +*/ } -- cgit v1.2.3