mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[shell32.dll]
- Initialize uninitialized variables. - Add code to guard against potential NULL pointer dereferencing. Thanks to Amine Khaldi for pointing out all these. svn path=/branches/shell32_new-bringup/; revision=53633
This commit is contained in:
parent
ea0da4a0a3
commit
261ee4dd58
11 changed files with 1017 additions and 901 deletions
|
@ -147,8 +147,14 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
|
|||
|
||||
/* pwszRegKeyPath contains the key as well as the value, so we split */
|
||||
key = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwzsRegKeyPath) + 1) * sizeof(WCHAR));
|
||||
|
||||
if (key)
|
||||
{
|
||||
wcscpy(key, pwzsRegKeyPath);
|
||||
value = const_cast<WCHAR *>(strrchrW(key, '\\'));
|
||||
|
||||
if (value)
|
||||
{
|
||||
*value = 0;
|
||||
value++;
|
||||
/* Now value contains the value and buffer the key */
|
||||
|
@ -170,14 +176,31 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
|
|||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc Failed when trying to alloca %d bytes\n", (wcslen(pwzsRegKeyPath) + 1) * sizeof(WCHAR));
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((pwszQuickComplete) && (!quickComplete))
|
||||
{
|
||||
quickComplete = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwszQuickComplete) + 1) * sizeof(WCHAR));
|
||||
|
||||
if (quickComplete)
|
||||
{
|
||||
wcscpy(quickComplete, pwszQuickComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc Failed when trying to alloca %d bytes\n", (wcslen(pwszQuickComplete) + 1) * sizeof(WCHAR));
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -314,6 +337,8 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
|
|||
len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL);
|
||||
msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
|
||||
|
||||
if (msg)
|
||||
{
|
||||
SendMessageW(pThis->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
|
||||
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
|
||||
SendMessageW(hwnd, EM_SETSEL, wcslen(msg), wcslen(msg));
|
||||
|
@ -321,6 +346,11 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
|
|||
HeapFree(GetProcessHeap(), 0, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc failed to allocate %d bytes\n", (len + 1) * sizeof(WCHAR));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)pThis->txtbackup);
|
||||
SendMessageW(hwnd, EM_SETSEL, wcslen(pThis->txtbackup), wcslen(pThis->txtbackup));
|
||||
|
@ -362,9 +392,17 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
|
|||
SendMessageW(pThis->hwndListBox, LB_RESETCONTENT, 0, 0);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, pThis->txtbackup);
|
||||
pThis->txtbackup = (WCHAR *)HeapAlloc(GetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY, (wcslen(hwndText)+1)*sizeof(WCHAR));
|
||||
|
||||
pThis->txtbackup = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(hwndText)+1)*sizeof(WCHAR));
|
||||
|
||||
if (pThis->txtbackup)
|
||||
{
|
||||
wcscpy(pThis->txtbackup, hwndText);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc failed to allocate %d bytes\n", (wcslen(hwndText)+1)*sizeof(WCHAR));
|
||||
}
|
||||
|
||||
/* Returns if there is no text to search and we doesn't want to display all the entries */
|
||||
if ((!displayall) && (! *hwndText) )
|
||||
|
@ -454,12 +492,19 @@ LRESULT APIENTRY CAutoComplete::ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM
|
|||
len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, 0);
|
||||
msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
|
||||
|
||||
if (msg)
|
||||
{
|
||||
SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
|
||||
SendMessageW(pThis->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
|
||||
SendMessageW(pThis->hwndEdit, EM_SETSEL, 0, wcslen(msg));
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc failed to allocate %d bytes\n", (len + 1) * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
}; break;
|
||||
|
||||
|
|
|
@ -340,7 +340,11 @@ BOOL pcheck( LPCITEMIDLIST pidl )
|
|||
|
||||
while( pidltemp && pidltemp->mkid.cb )
|
||||
{
|
||||
type = _dbg_ILGetDataPointer(pidltemp)->type;
|
||||
LPPIDLDATA pidlData = _dbg_ILGetDataPointer(pidltemp);
|
||||
|
||||
if (pidlData)
|
||||
{
|
||||
type = pidlData->type;
|
||||
switch( type )
|
||||
{
|
||||
case PT_CPLAPPLET:
|
||||
|
@ -371,6 +375,11 @@ BOOL pcheck( LPCITEMIDLIST pidl )
|
|||
}
|
||||
pidltemp = _dbg_ILGetNext(pidltemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@
|
|||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
HWND hwndOwner ;
|
||||
HICON hIcon ;
|
||||
LPCWSTR lpstrDirectory ;
|
||||
LPCWSTR lpstrTitle ;
|
||||
LPCWSTR lpstrDescription ;
|
||||
UINT uFlags ;
|
||||
} RUNFILEDLGPARAMS ;
|
||||
} RUNFILEDLGPARAMS ;
|
||||
|
||||
typedef BOOL (WINAPI * LPFNOFN) (OPENFILENAMEW *) ;
|
||||
|
||||
|
@ -309,6 +309,12 @@ static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
|
|||
|
||||
result = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));
|
||||
|
||||
if (NULL == result)
|
||||
{
|
||||
TRACE("HeapAlloc couldn't allocate %d bytes\n", sizeof(WCHAR)*(strlenW(cmdline)+5));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
src = cmdline;
|
||||
dest = result;
|
||||
|
||||
|
@ -404,6 +410,9 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
|
|||
ZeroMemory (&sei, sizeof(sei)) ;
|
||||
sei.cbSize = sizeof(sei) ;
|
||||
psz = (WCHAR *)HeapAlloc( GetProcessHeap(), 0, (ic + 1)*sizeof(WCHAR) );
|
||||
|
||||
if (psz)
|
||||
{
|
||||
GetWindowTextW (htxt, psz, ic + 1) ;
|
||||
|
||||
/* according to http://www.codeproject.com/KB/shell/runfiledlg.aspx we should send a
|
||||
|
@ -435,6 +444,7 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
|
|||
EndDialog (hwnd, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case IDCANCEL :
|
||||
EndDialog (hwnd, 0) ;
|
||||
|
@ -491,7 +501,7 @@ static INT_PTR CALLBACK RunDlgProc (HWND hwnd, UINT message, WPARAM wParam, LPAR
|
|||
/* This grabs the MRU list from the registry and fills the combo for the "Run" dialog above */
|
||||
/* fShowDefault ignored if pszLatest != NULL */
|
||||
static void FillList (HWND hCb, char *pszLatest, BOOL fShowDefault)
|
||||
{
|
||||
{
|
||||
HKEY hkey ;
|
||||
/* char szDbgMsg[256] = "" ; */
|
||||
char *pszList = NULL, *pszCmd = NULL, cMatch = 0, cMax = 0x60, szIndex[2] = "-" ;
|
||||
|
@ -510,8 +520,16 @@ static void FillList (HWND hCb, char *pszLatest, BOOL fShowDefault)
|
|||
if (icList > 0)
|
||||
{
|
||||
pszList = (char *)HeapAlloc( GetProcessHeap(), 0, icList) ;
|
||||
|
||||
if (pszList)
|
||||
{
|
||||
if (ERROR_SUCCESS != RegQueryValueExA (hkey, "MRUList", NULL, NULL, (LPBYTE)pszList, &icList))
|
||||
MessageBoxA (hCb, "Unable to grab MRUList !", "Nix", MB_OK) ;
|
||||
MessageBoxA (hCb, "Unable to grab MRUList !", "Nix", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc failed to allocate %d bytes\n", icList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -567,7 +585,6 @@ static void FillList (HWND hCb, char *pszLatest, BOOL fShowDefault)
|
|||
SetWindowTextA (hCb, pszCmd) ;
|
||||
SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -598,21 +615,29 @@ static void FillList (HWND hCb, char *pszLatest, BOOL fShowDefault)
|
|||
SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
|
||||
|
||||
cMatch = ++cMax ;
|
||||
if( pszList )
|
||||
if (pszList)
|
||||
pszList = (char *)HeapReAlloc(GetProcessHeap(), 0, pszList, ++icList) ;
|
||||
else
|
||||
pszList = (char *)HeapAlloc(GetProcessHeap(), 0, ++icList) ;
|
||||
|
||||
if (pszList)
|
||||
{
|
||||
memmove (&pszList[1], pszList, icList - 1) ;
|
||||
pszList[0] = cMatch ;
|
||||
szIndex[0] = cMatch ;
|
||||
RegSetValueExA (hkey, szIndex, 0, REG_SZ, (LPBYTE)pszLatest, strlen (pszLatest) + 1) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("HeapAlloc or HeapReAlloc failed to allocate enough bytes\n");
|
||||
}
|
||||
}
|
||||
|
||||
RegSetValueExA (hkey, "MRUList", 0, REG_SZ, (LPBYTE)pszList, strlen (pszList) + 1) ;
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, pszCmd) ;
|
||||
HeapFree( GetProcessHeap(), 0, pszList) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -101,8 +101,11 @@ BOOL IEnumIDListImpl::DeleteList()
|
|||
BOOL IEnumIDListImpl::HasItemWithCLSID(LPITEMIDLIST pidl)
|
||||
{
|
||||
ENUMLIST *pCur;
|
||||
REFIID refid = *_ILGetGUIDPointer(pidl);
|
||||
IID *ptr = _ILGetGUIDPointer(pidl);
|
||||
|
||||
if (ptr)
|
||||
{
|
||||
REFIID refid = *ptr;
|
||||
pCur = mpFirst;
|
||||
|
||||
while(pCur)
|
||||
|
@ -114,6 +117,8 @@ BOOL IEnumIDListImpl::HasItemWithCLSID(LPITEMIDLIST pidl)
|
|||
}
|
||||
pCur = pCur->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -179,6 +184,7 @@ BOOL IEnumIDListImpl::CreateFolderEnumList(
|
|||
} while (succeeded && !findFinished);
|
||||
FindClose(hFile);
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ CDrivesFolderEnum::~CDrivesFolderEnum()
|
|||
|
||||
HRESULT WINAPI CDrivesFolderEnum::Initialize(HWND hwndOwner, DWORD dwFlags)
|
||||
{
|
||||
DbgPrint("[shell32, CDrivesFolderEnum::Initialize] Called with flags = %d\n", dwFlags);
|
||||
|
||||
if (CreateMyCompEnumList(dwFlags) == FALSE)
|
||||
return E_FAIL;
|
||||
return S_OK;
|
||||
|
@ -97,6 +99,8 @@ BOOL CDrivesFolderEnum::CreateMyCompEnumList(DWORD dwFlags)
|
|||
|
||||
TRACE("(%p)->(flags=0x%08x)\n", this, dwFlags);
|
||||
|
||||
DbgPrint("[shell32, CDrivesFolderEnum::CreateMyCompEnumList] Called with flags = %d\n", dwFlags);
|
||||
|
||||
/* enumerate the folders */
|
||||
if (dwFlags & SHCONTF_FOLDERS)
|
||||
{
|
||||
|
@ -114,7 +118,8 @@ BOOL CDrivesFolderEnum::CreateMyCompEnumList(DWORD dwFlags)
|
|||
}
|
||||
|
||||
TRACE("-- (%p)-> enumerate (mycomputer shell extensions)\n", this);
|
||||
for (i=0; i<2; i++) {
|
||||
for (i=0; i<2; i++)
|
||||
{
|
||||
if (ret && !RegOpenKeyExW(i == 0 ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
|
||||
MyComputer_NameSpaceW, 0, KEY_READ, &hkey))
|
||||
{
|
||||
|
@ -255,18 +260,26 @@ HRESULT WINAPI CDrivesFolder::EnumObjects (HWND hwndOwner, DWORD dwFlags, LPENUM
|
|||
|
||||
TRACE ("(%p)->(HWND=%p flags=0x%08x pplist=%p)\n", this, hwndOwner, dwFlags, ppEnumIDList);
|
||||
|
||||
DbgPrint("[shell32, CDrivesFolder::EnumObjects] Called with flags = %d\n", dwFlags);
|
||||
|
||||
if (ppEnumIDList == NULL)
|
||||
return E_POINTER;
|
||||
|
||||
*ppEnumIDList = NULL;
|
||||
ATLTRY (theEnumerator = new CComObject<CDrivesFolderEnum>);
|
||||
|
||||
if (theEnumerator == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
hResult = theEnumerator->QueryInterface (IID_IEnumIDList, (void **)&result);
|
||||
if (FAILED (hResult))
|
||||
{
|
||||
delete theEnumerator;
|
||||
return hResult;
|
||||
}
|
||||
|
||||
DbgPrint("[shell32, CDrivesFolder::EnumObjects] Calling theEnumerator->Initialize\n");
|
||||
|
||||
hResult = theEnumerator->Initialize (hwndOwner, dwFlags);
|
||||
if (FAILED (hResult))
|
||||
return hResult;
|
||||
|
|
|
@ -327,6 +327,7 @@ CPrinterFolder::CPrinterFolder()
|
|||
{
|
||||
pidlRoot = NULL;
|
||||
dwAttributes = 0;
|
||||
pclsid = NULL;
|
||||
}
|
||||
|
||||
CPrinterFolder::~CPrinterFolder()
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
#include <windef.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(exec);
|
||||
|
||||
|
|
|
@ -660,7 +660,7 @@ IDefaultContextMenuImpl::AddStaticContextMenusToMenu(
|
|||
}
|
||||
else
|
||||
{
|
||||
TRACE("Failed to laod string, defaulting to default (NULL) value for mii.dwTypeData\n");
|
||||
TRACE("Failed to load string, defaulting to NULL value for mii.dwTypeData\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -87,6 +87,21 @@ GetKeyDescription(LPWSTR szKeyName, LPWSTR szResult)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void CNewMenu::UnloadItem(SHELLNEW_ITEM *item)
|
||||
{
|
||||
// bail if the item is clearly invalid
|
||||
if (NULL == item)
|
||||
return;
|
||||
|
||||
if (NULL != item->szTarget)
|
||||
free(item->szTarget);
|
||||
|
||||
free(item->szDesc);
|
||||
free(item->szIcon);
|
||||
free(item->szExt);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, item);
|
||||
}
|
||||
|
||||
CNewMenu::SHELLNEW_ITEM *CNewMenu::LoadItem(LPWSTR szKeyName)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
CNewMenu();
|
||||
~CNewMenu();
|
||||
SHELLNEW_ITEM *LoadItem(LPWSTR szKeyName);
|
||||
void UnloadItem(SHELLNEW_ITEM *item);
|
||||
BOOL LoadShellNewItems();
|
||||
UINT InsertShellNewItems(HMENU hMenu, UINT idFirst, UINT idMenu);
|
||||
HRESULT DoShellNewCmd(LPCMINVOKECOMMANDINFO lpcmi);
|
||||
|
|
Loading…
Reference in a new issue