Commit 92747f25 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

CreateItemMoniker may get NULL as szDelim, some cleanups.

parent 52475287
...@@ -342,8 +342,9 @@ HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface, ...@@ -342,8 +342,9 @@ HRESULT WINAPI ItemMonikerImpl_GetSizeMax(IMoniker* iface,
HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem) HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDelim,LPCOLESTR lpszItem)
{ {
int sizeStr1=lstrlenW(lpszItem); int sizeStr1=lstrlenW(lpszItem), sizeStr2;
int sizeStr2=lstrlenW(lpszDelim); static const OLECHAR emptystr[1];
LPCOLESTR delim;
TRACE("(%p,%p)\n",This,lpszItem); TRACE("(%p,%p)\n",This,lpszItem);
...@@ -353,14 +354,22 @@ HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDe ...@@ -353,14 +354,22 @@ HRESULT WINAPI ItemMonikerImpl_Construct(ItemMonikerImpl* This, LPCOLESTR lpszDe
This->ref = 0; This->ref = 0;
This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1)); This->itemName=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr1+1));
This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1)); if (!This->itemName)
return E_OUTOFMEMORY;
strcpyW(This->itemName,lpszItem);
if ((This->itemName==NULL)||(This->itemDelimiter==NULL)) if (!lpszDelim)
return E_OUTOFMEMORY; FIXME("lpszDelim is NULL. Using empty string which is possibly wrong.\n");
strcpyW(This->itemName,lpszItem); delim = lpszDelim ? lpszDelim : emptystr;
strcpyW(This->itemDelimiter,lpszDelim);
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; return S_OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment