mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
CreateItemMoniker may get NULL as szDelim, some cleanups.
This commit is contained in:
parent
52475287da
commit
92747f2543
1 changed files with 17 additions and 8 deletions
|
@ -342,8 +342,9 @@ HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface,
|
|||
HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem)
|
||||
{
|
||||
|
||||
int sizeStr1=lstrlenW(lpszItem);
|
||||
int sizeStr2=lstrlenW(lpszDelim);
|
||||
int sizeStr1=lstrlenW(lpszItem), sizeStr2;
|
||||
static const OLECHAR emptystr[1];
|
||||
LPCOLESTR delim;
|
||||
|
||||
TRACE("(%p,%p)\n",This,lpszItem);
|
||||
|
||||
|
@ -353,14 +354,22 @@ HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDe
|
|||
This->ref = 0;
|
||||
|
||||
This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1));
|
||||
This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1));
|
||||
|
||||
if ((This->itemName==NULL)||(This->itemDelimiter==NULL))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (!This->itemName)
|
||||
return E_OUTOFMEMORY;
|
||||
strcpyW(This->itemName,lpszItem);
|
||||
strcpyW(This->itemDelimiter,lpszDelim);
|
||||
|
||||
if (!lpszDelim)
|
||||
FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
|
||||
|
||||
delim = lpszDelim ? lpszDelim : emptystr;
|
||||
|
||||
sizeStr2=strlenW(delim);
|
||||
This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1));
|
||||
if (!This->itemDelimiter) {
|
||||
HeapFree(GetProcessHeap(),0,This->itemName);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
strcpyW(This->itemDelimiter,delim);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue