diff --git a/cmd/synergyc/synergyc.cpp b/cmd/synergyc/synergyc.cpp index 7bf854be..a16d3407 100644 --- a/cmd/synergyc/synergyc.cpp +++ b/cmd/synergyc/synergyc.cpp @@ -540,13 +540,15 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int) // users on NT can use `--daemon' or `--no-daemon' to force us out // of the service code path. if (__argc <= 1 && !CArchMiscWindows::isWindows95Family()) { + int result = kExitFailed; try { - return ARCH->daemonize(DAEMON_NAME, &daemonStartup); + result = ARCH->daemonize(DAEMON_NAME, &daemonStartup); } catch (XArchDaemon& e) { LOG((CLOG_CRIT "failed to start as a service: %s" BYE, e.what().c_str(), ARG->m_pname)); - return kExitFailed; } + delete CLOG; + return result; } // parse command line @@ -586,6 +588,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int) MessageBox(NULL, msg, ARG->m_pname, MB_OK | MB_ICONWARNING); } + delete CLOG; return result; } diff --git a/cmd/synergys/synergys.cpp b/cmd/synergys/synergys.cpp index c535aab7..0e676d0a 100644 --- a/cmd/synergys/synergys.cpp +++ b/cmd/synergys/synergys.cpp @@ -672,13 +672,15 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int) // users on NT can use `--daemon' or `--no-daemon' to force us out // of the service code path. if (__argc <= 1 && !CArchMiscWindows::isWindows95Family()) { + int result = kExitFailed; try { - return ARCH->daemonize(DAEMON_NAME, &daemonStartup); + result = ARCH->daemonize(DAEMON_NAME, &daemonStartup); } catch (XArchDaemon& e) { LOG((CLOG_CRIT "failed to start as a service: %s" BYE, e.what().c_str(), ARG->m_pname)); - return kExitFailed; } + delete CLOG; + return result; } // parse command line @@ -721,6 +723,7 @@ WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int) MessageBox(NULL, msg, ARG->m_pname, MB_OK | MB_ICONWARNING); } + delete CLOG; return result; } diff --git a/lib/arch/CArchMultithreadWindows.cpp b/lib/arch/CArchMultithreadWindows.cpp index a44fe6b7..315a3979 100644 --- a/lib/arch/CArchMultithreadWindows.cpp +++ b/lib/arch/CArchMultithreadWindows.cpp @@ -97,6 +97,15 @@ CArchMultithreadWindows::CArchMultithreadWindows() CArchMultithreadWindows::~CArchMultithreadWindows() { s_instance = NULL; + + // clean up thread list + for (CThreadList::iterator index = m_threadList.begin(); + index != m_threadList.end(); ++index) { + delete *index; + } + + // done with mutex + delete m_threadMutex; } HANDLE diff --git a/lib/base/CUnicode.cpp b/lib/base/CUnicode.cpp index 5cac46d6..9d8fd8d2 100644 --- a/lib/base/CUnicode.cpp +++ b/lib/base/CUnicode.cpp @@ -406,6 +406,7 @@ CUnicode::textToUTF8(const CString& src, bool* errors) // clean up delete[] wcs; + ARCH->closeMBState(state); return utf8; }