Author: dquintana
Date: Tue Oct 21 12:24:15 2014
New Revision: 64864
URL: 
http://svn.reactos.org/svn/reactos?rev=64864&view=rev
Log:
[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.
Modified:
    branches/shell-experiments/base/shell/explorer-new/shellservice.c
    branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
    branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp
    branches/shell-experiments/dll/win32/browseui/bandsite.cpp
    branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp
    branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp
    branches/shell-experiments/dll/win32/shell32/shlview.cpp
Modified: branches/shell-experiments/base/shell/explorer-new/shellservice.c
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/ex…
==============================================================================
--- branches/shell-experiments/base/shell/explorer-new/shellservice.c   [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/explorer-new/shellservice.c   [iso-8859-1] Tue
Oct 21 12:24:15 2014
@@ -61,7 +61,7 @@
     HRESULT hr = S_OK;
     int     count = 0;
-    hdpa = DPA_Create(5);
+    *phdpa = NULL;
     TRACE("Enumerating Shell Service Ojbect GUIDs...\n");
@@ -72,6 +72,8 @@
         ERR("RegOpenKey failed.\n");
         return HRESULT_FROM_WIN32(GetLastError());
     }
+
+    hdpa = DPA_Create(5);
     /* Enumerate */
     do
Modified: branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp       [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/rshell/CMenuDeskBar.cpp       [iso-8859-1] Tue
Oct 21 12:24:15 2014
@@ -35,8 +35,11 @@
 CMenuDeskBar::CMenuDeskBar() :
     m_Client(NULL),
+    m_ClientWindow(NULL),
+    m_IconSize(0),
     m_Banner(NULL),
-    m_Shown(FALSE)
+    m_Shown(FALSE),
+    m_ShowFlags(0)
 {
 }
Modified: branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/base/shell/rs…
==============================================================================
--- branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp      [iso-8859-1]
(original)
+++ branches/shell-experiments/base/shell/rshell/CMenuToolbars.cpp      [iso-8859-1] Tue
Oct 21 12:24:15 2014
@@ -1191,7 +1191,10 @@
             HRESULT hr = m_menuBand->_CallCBWithItemId(info.wID, SMC_GETINFO, 0,
reinterpret_cast<LPARAM>(sminfo));
             if (FAILED_UNEXPECTEDLY(hr))
+            {
+                delete sminfo;
                 return hr;
+            }
             AddButton(info.wID, info.dwTypeData, info.hSubMenu != NULL, sminfo->iIcon,
reinterpret_cast<DWORD_PTR>(sminfo), last);
Modified: branches/shell-experiments/dll/win32/browseui/bandsite.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/bandsite.cpp  [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/browseui/bandsite.cpp  [iso-8859-1] Tue Oct 21
12:24:15 2014
@@ -337,7 +337,6 @@
         /* Initialize the added bands */
         memset(&NewBand[fBandsAllocated], 0, (NewAllocated - fBandsAllocated) *
sizeof(struct BandObject));
-        NewBand = &fBands[fBandsAllocated];
         fBandsAllocated = NewAllocated;
         CoTaskMemFree(fBands);
         fBands = NewBand;
Modified: branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp   [iso-8859-1]
(original)
+++ branches/shell-experiments/dll/win32/browseui/internettoolbar.cpp   [iso-8859-1] Tue
Oct 21 12:24:15 2014
@@ -30,6 +30,7 @@
 #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 = 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 (hrs)
-    {
-        PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(hrs,
"CMenuBand_Constructor");
+    if (!g_hRShell) g_hRShell = LoadLibraryW(L"rshell.dll");
+
+    if (g_hRShell)
+    {
+        PMENUBAND_CONSTRUCTOR func = (PMENUBAND_CONSTRUCTOR) GetProcAddress(g_hRShell,
"CMenuBand_Constructor");
         if (func)
         {
             hResult = func(IID_PPV_ARG(IShellMenu, &menubar));
Modified: branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/bro…
==============================================================================
--- branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp      [iso-8859-1]
(original)
+++ branches/shell-experiments/dll/win32/browseui/shellbrowser.cpp      [iso-8859-1] Tue
Oct 21 12:24:15 2014
@@ -897,28 +897,32 @@
     LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
 {
     CComPtr<IShellFolder>                   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<LPCITEMIDLIST
*>(&childPIDL), rgfInOut);
         if (FAILED(hResult))
-            return hResult;
-    }
-
-    ILFree(childPIDL);
-    return S_OK;
+            goto cleanup;
+    }
+
+    hResult = S_OK;
+
+cleanup:
+    if (childPIDL)
+        ILFree(childPIDL);
+    return hResult;
 }
 long IEGetNameAndFlags(LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf,
SFGAOF *rgfInOut)
Modified: branches/shell-experiments/dll/win32/shell32/shlview.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/shell-experiments/dll/win32/she…
==============================================================================
--- branches/shell-experiments/dll/win32/shell32/shlview.cpp    [iso-8859-1] (original)
+++ branches/shell-experiments/dll/win32/shell32/shlview.cpp    [iso-8859-1] Tue Oct 21
12:24:15 2014
@@ -59,7 +59,8 @@
 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 @@
     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()