From ea3ab8f3a8ed69436d3350ac15593394fc7e0e56 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Tue, 16 Dec 2014 13:11:12 +0000 Subject: Fixed minor leaks git-svn-id: http://svn.miranda-ng.org/main/trunk@11457 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/genmenu.cpp | 2 +- src/modules/database/database.cpp | 1 + src/modules/plugins/newplugins.cpp | 38 ++++++++++++++++++-------------------- src/modules/utils/openurl.cpp | 22 ++++++++++------------ 4 files changed, 30 insertions(+), 33 deletions(-) (limited to 'src/modules') diff --git a/src/modules/clist/genmenu.cpp b/src/modules/clist/genmenu.cpp index 93dd2c0b7e..69bd36cb93 100644 --- a/src/modules/clist/genmenu.cpp +++ b/src/modules/clist/genmenu.cpp @@ -411,7 +411,7 @@ INT_PTR MO_ProcessCommandByMenuIdent(WPARAM wParam, LPARAM lParam) if (!bIsGenMenuInited) return -1; - PMO_IntMenuItem pimi; + PMO_IntMenuItem pimi = NULL; { mir_cslock lck(csMenuHook); for (int i=0; i < g_menus.getCount(); i++) diff --git a/src/modules/database/database.cpp b/src/modules/database/database.cpp index f6b4c2d34b..73794631d3 100644 --- a/src/modules/database/database.cpp +++ b/src/modules/database/database.cpp @@ -213,6 +213,7 @@ static void moveProfileDirProfiles(TCHAR *profiledir, BOOL isRootDir = TRUE) TranslateT("Miranda is trying to upgrade your profile structure.\nIt cannot move profile %s to the new location %s automatically\nMost likely due to insufficient privileges. Please move profile manually."), path, path2); MessageBox(NULL, buf, _T("Miranda NG"), MB_ICONERROR | MB_OK); + mir_free(profile); break; } mir_free(profile); diff --git a/src/modules/plugins/newplugins.cpp b/src/modules/plugins/newplugins.cpp index 2e2885033e..70fcb8ca4d 100644 --- a/src/modules/plugins/newplugins.cpp +++ b/src/modules/plugins/newplugins.cpp @@ -246,9 +246,7 @@ static int checkPI(BASIC_PLUGIN_INFO* bpi, PLUGININFOEX* pi) int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI) { - HINSTANCE h = NULL; - - h = LoadLibrary(plugin); + HINSTANCE h = LoadLibrary(plugin); if (h == NULL) return 0; @@ -283,16 +281,15 @@ LBL_Ok: bpi->hInst = h; return 1; } - // check clist ? - if (checkTypeAPI == CHECKAPI_CLIST) { + else if (checkTypeAPI == CHECKAPI_CLIST) { bpi->clistlink = (CList_Initialise)GetProcAddress(h, "CListInitialise"); if (pi->flags & UNICODE_AWARE) if (bpi->clistlink) goto LBL_Ok; } - - goto LBL_Error; + else + goto LBL_Error; } // perform any API related tasks to freeing @@ -310,11 +307,12 @@ void Plugin_Uninit(pluginEntry *p) // we need to kill all resources which belong to that DLL before calling FreeLibrary KillModuleEventHooks(hInst); KillModuleServices(hInst); + UnregisterModule(hInst); FreeLibrary(hInst); memset(&p->bpi, 0, sizeof(p->bpi)); } - UnregisterModule(hInst); + if (p == pluginList_crshdmp) pluginList_crshdmp = NULL; pluginList.remove(p); @@ -382,18 +380,18 @@ void enumPlugins(SCAN_PLUGINS_CALLBACK cb, WPARAM wParam, LPARAM lParam) // create the search filter TCHAR search[MAX_PATH]; mir_sntprintf(search, SIZEOF(search), _T("%s\\Plugins\\*.dll"), exe); - { - // FFFN will return filenames for things like dot dll+ or dot dllx - WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile(search, &ffd); - if (hFind != INVALID_HANDLE_VALUE) { - do { - if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && valid_library_name(ffd.cFileName)) - cb(&ffd, exe, wParam, lParam); - } while (FindNextFile(hFind, &ffd)); - FindClose(hFind); - } //if - } + + // FFFN will return filenames for things like dot dll+ or dot dllx + WIN32_FIND_DATA ffd; + HANDLE hFind = FindFirstFile(search, &ffd); + if (hFind == INVALID_HANDLE_VALUE) + return; + + do { + if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && valid_library_name(ffd.cFileName)) + cb(&ffd, exe, wParam, lParam); + } while (FindNextFile(hFind, &ffd)); + FindClose(hFind); } pluginEntry* OpenPlugin(TCHAR *tszFileName, TCHAR *dir, TCHAR *path) diff --git a/src/modules/utils/openurl.cpp b/src/modules/utils/openurl.cpp index 7228182874..ab1797e2c5 100644 --- a/src/modules/utils/openurl.cpp +++ b/src/modules/utils/openurl.cpp @@ -34,7 +34,7 @@ typedef struct { static void OpenURLThread(void *arg) { TOpenUrlInfo *hUrlInfo = (TOpenUrlInfo*)arg; - if (!hUrlInfo->szUrl) + if (!hUrlInfo || !hUrlInfo->szUrl) return; //wack a protocol on it @@ -47,20 +47,18 @@ static void OpenURLThread(void *arg) int i; for (i=0; _istalpha(hUrlInfo->szUrl[i]); i++); if (hUrlInfo->szUrl[i] == ':') - szResult = mir_tstrdup(hUrlInfo->szUrl); - else { - if (!_tcsnicmp(hUrlInfo->szUrl, _T("ftp."), 4)) - mir_sntprintf(szResult, size, _T("ftp://%s"), hUrlInfo->szUrl); - else - mir_sntprintf(szResult, size, _T("http://%s"), hUrlInfo->szUrl); - } + mir_tstrcpy(szResult, hUrlInfo->szUrl); + else if (!_tcsnicmp(hUrlInfo->szUrl, _T("ftp."), 4)) + mir_sntprintf(szResult, size, _T("ftp://%s"), hUrlInfo->szUrl); + else + mir_sntprintf(szResult, size, _T("http://%s"), hUrlInfo->szUrl); } // check user defined browser for opening urls - DBVARIANT dbv; - if (!db_get_ts(NULL, "Miranda", "OpenUrlBrowser", &dbv)) { - ShellExecute(NULL, _T("open"), dbv.ptszVal, szResult, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT); - db_free(&dbv); + TCHAR *tszBrowser = db_get_tsa(NULL, "Miranda", "OpenUrlBrowser"); + if (tszBrowser) { + ShellExecute(NULL, _T("open"), tszBrowser, szResult, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT); + mir_free(tszBrowser); } else ShellExecute(NULL, _T("open"), szResult, NULL, NULL, (hUrlInfo->newWindow) ? SW_NORMAL : SW_SHOWDEFAULT); -- cgit v1.2.3