From 9abc368186f0af59520e6dcff5973cf2e92c966f Mon Sep 17 00:00:00 2001 From: David Quintana Date: Tue, 21 Oct 2014 12:24:15 +0000 Subject: [PATCH] [EXPLORER-NEW] * Cleanup in case of error. CID 1248426 [RSHELL] * Add uninitialized class fields. CID 1248477 * Avoid leaking memory. CID 1248438 [BROWSEUI] * Fix potential overwriting of a variable. CID 716363 * Save the rshell handle instead of loading it every time. CID 1248435 * Fix leaked PIDL. CID 1248418 [SHELL32] * Fix GCC build. And one small nickpick that has been bothering me for a long time. svn path=/branches/shell-experiments/; revision=64864 --- base/shell/explorer-new/shellservice.c | 4 +++- base/shell/rshell/CMenuDeskBar.cpp | 5 ++++- base/shell/rshell/CMenuToolbars.cpp | 3 +++ dll/win32/browseui/bandsite.cpp | 1 - dll/win32/browseui/internettoolbar.cpp | 9 +++++---- dll/win32/browseui/shellbrowser.cpp | 16 ++++++++++------ dll/win32/shell32/shlview.cpp | 11 ++++++----- 7 files changed, 31 insertions(+), 18 deletions(-) diff --git a/base/shell/explorer-new/shellservice.c b/base/shell/explorer-new/shellservice.c index abafc5d561f..02d3600a2f4 100644 --- a/base/shell/explorer-new/shellservice.c +++ b/base/shell/explorer-new/shellservice.c @@ -61,7 +61,7 @@ HRESULT InitShellServices(HDPA * phdpa) HRESULT hr = S_OK; int count = 0; - hdpa = DPA_Create(5); + *phdpa = NULL; TRACE("Enumerating Shell Service Ojbect GUIDs...\n"); @@ -73,6 +73,8 @@ HRESULT InitShellServices(HDPA * phdpa) return HRESULT_FROM_WIN32(GetLastError()); } + hdpa = DPA_Create(5); + /* Enumerate */ do { diff --git a/base/shell/rshell/CMenuDeskBar.cpp b/base/shell/rshell/CMenuDeskBar.cpp index 96cf7b3a5b1..fd3f8431fca 100644 --- a/base/shell/rshell/CMenuDeskBar.cpp +++ b/base/shell/rshell/CMenuDeskBar.cpp @@ -35,8 +35,11 @@ HRESULT WINAPI CMenuDeskBar_Constructor(REFIID riid, LPVOID *ppv) CMenuDeskBar::CMenuDeskBar() : m_Client(NULL), + m_ClientWindow(NULL), + m_IconSize(0), m_Banner(NULL), - m_Shown(FALSE) + m_Shown(FALSE), + m_ShowFlags(0) { } diff --git a/base/shell/rshell/CMenuToolbars.cpp b/base/shell/rshell/CMenuToolbars.cpp index 14bcc5179fa..5ea31b2f224 100644 --- a/base/shell/rshell/CMenuToolbars.cpp +++ b/base/shell/rshell/CMenuToolbars.cpp @@ -1191,7 +1191,10 @@ HRESULT CMenuStaticToolbar::FillToolbar(BOOL clearFirst) HRESULT hr = m_menuBand->_CallCBWithItemId(info.wID, SMC_GETINFO, 0, reinterpret_cast(sminfo)); if (FAILED_UNEXPECTEDLY(hr)) + { + delete sminfo; return hr; + } AddButton(info.wID, info.dwTypeData, info.hSubMenu != NULL, sminfo->iIcon, reinterpret_cast(sminfo), last); diff --git a/dll/win32/browseui/bandsite.cpp b/dll/win32/browseui/bandsite.cpp index 2be4d674c76..602dd9b7aca 100644 --- a/dll/win32/browseui/bandsite.cpp +++ b/dll/win32/browseui/bandsite.cpp @@ -337,7 +337,6 @@ HRESULT STDMETHODCALLTYPE CBandSiteBase::AddBand(IUnknown *punk) /* Initialize the added bands */ memset(&NewBand[fBandsAllocated], 0, (NewAllocated - fBandsAllocated) * sizeof(struct BandObject)); - NewBand = &fBands[fBandsAllocated]; fBandsAllocated = NewAllocated; CoTaskMemFree(fBands); fBands = NewBand; diff --git a/dll/win32/browseui/internettoolbar.cpp b/dll/win32/browseui/internettoolbar.cpp index 3a86b5067dd..d7160924b1c 100644 --- a/dll/win32/browseui/internettoolbar.cpp +++ b/dll/win32/browseui/internettoolbar.cpp @@ -30,6 +30,7 @@ toolbar, and address band for an explorer window #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp)) #define USE_CUSTOM_MENUBAND 1 +HMODULE g_hRShell = NULL; #if 1 // TODO: declare these GUIDs and interfaces in the right place (whatever that may be) @@ -729,13 +730,13 @@ HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **pMenuBar) hResult = E_FAIL; #if USE_CUSTOM_MENUBAND - HMODULE hrs = GetModuleHandleW(L"rshell.dll"); + if (!g_hRShell) g_hRShell = GetModuleHandleW(L"rshell.dll"); - if (!hrs) hrs = LoadLibraryW(L"rshell.dll"); + if (!g_hRShell) g_hRShell = LoadLibraryW(L"rshell.dll"); - if (hrs) + if (g_hRShell) { - PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs, "CMenuBand_Constructor"); + PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(g_hRShell, "CMenuBand_Constructor"); if (func) { hResult = func(IID_PPV_ARG(IShellMenu, &menubar)); diff --git a/dll/win32/browseui/shellbrowser.cpp b/dll/win32/browseui/shellbrowser.cpp index b45f116bbbe..1ffb0f2f08f 100644 --- a/dll/win32/browseui/shellbrowser.cpp +++ b/dll/win32/browseui/shellbrowser.cpp @@ -897,28 +897,32 @@ HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut) { CComPtr parentFolder; - LPITEMIDLIST childPIDL; + LPITEMIDLIST childPIDL = NULL; STRRET L108; HRESULT hResult; hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL); if (FAILED(hResult)) - return hResult; + goto cleanup; hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108); if (FAILED(hResult)) - return hResult; + goto cleanup; StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf); if (rgfInOut) { hResult = parentFolder->GetAttributesOf(1, const_cast(&childPIDL), rgfInOut); if (FAILED(hResult)) - return hResult; + goto cleanup; } - ILFree(childPIDL); - return S_OK; + hResult = S_OK; + +cleanup: + if (childPIDL) + ILFree(childPIDL); + return hResult; } long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut) diff --git a/dll/win32/shell32/shlview.cpp b/dll/win32/shell32/shlview.cpp index b94b22286f7..b00e973227f 100644 --- a/dll/win32/shell32/shlview.cpp +++ b/dll/win32/shell32/shlview.cpp @@ -59,7 +59,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); static const WCHAR SV_CLASS_NAME[] = {'S', 'H', 'E', 'L', 'L', 'D', 'L', 'L', '_', 'D', 'e', 'f', 'V', 'i', 'e', 'w', 0}; typedef struct -{ BOOL bIsAscending; +{ + BOOL bIsAscending; INT nHeaderID; INT nLastHeaderID; } LISTVIEW_SORT_INFO, *LPLISTVIEW_SORT_INFO; @@ -358,10 +359,10 @@ CDefView::CDefView() : m_isEditing(FALSE), m_hView(NULL) { - m_FolderSettings = { 0 }; - m_sortInfo = { 0 }; - m_ptLastMousePos = { 0 }; - m_Category = { 0 }; + ZeroMemory(&m_FolderSettings, sizeof(m_FolderSettings)); + ZeroMemory(&m_sortInfo, sizeof(m_sortInfo)); + ZeroMemory(&m_ptLastMousePos, sizeof(m_ptLastMousePos)); + ZeroMemory(&m_Category, sizeof(m_Category)); } CDefView::~CDefView()