ole32: Remove stack-based string buffer inFileMonikerImpl_DecomposePath.
This commit is contained in:
parent
1d6d831099
commit
c2fdea600a
|
@ -1011,19 +1011,27 @@ FileMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** p
|
||||||
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
|
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
|
||||||
{
|
{
|
||||||
static const WCHAR bSlash[] = {'\\',0};
|
static const WCHAR bSlash[] = {'\\',0};
|
||||||
WCHAR word[MAX_PATH];
|
LPOLESTR word;
|
||||||
int i=0,j,tabIndex=0;
|
int i=0,j,tabIndex=0, ret=0;
|
||||||
LPOLESTR *strgtable ;
|
LPOLESTR *strgtable ;
|
||||||
|
|
||||||
int len=lstrlenW(str);
|
int len=lstrlenW(str);
|
||||||
|
|
||||||
TRACE("%s, %p\n", debugstr_w(str), *stringTable);
|
TRACE("%s, %p\n", debugstr_w(str), *stringTable);
|
||||||
|
|
||||||
strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
|
strgtable = CoTaskMemAlloc(len*sizeof(WCHAR));
|
||||||
|
|
||||||
if (strgtable==NULL)
|
if (strgtable==NULL)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
word = CoTaskMemAlloc((len + 1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
if (word==NULL)
|
||||||
|
{
|
||||||
|
ret = E_OUTOFMEMORY;
|
||||||
|
goto lend;
|
||||||
|
}
|
||||||
|
|
||||||
while(str[i]!=0){
|
while(str[i]!=0){
|
||||||
|
|
||||||
if(str[i]==bSlash[0]){
|
if(str[i]==bSlash[0]){
|
||||||
|
@ -1031,7 +1039,10 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
|
||||||
strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
|
strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
|
||||||
|
|
||||||
if (strgtable[tabIndex]==NULL)
|
if (strgtable[tabIndex]==NULL)
|
||||||
return E_OUTOFMEMORY;
|
{
|
||||||
|
ret = E_OUTOFMEMORY;
|
||||||
|
goto lend;
|
||||||
|
}
|
||||||
|
|
||||||
strcpyW(strgtable[tabIndex++],bSlash);
|
strcpyW(strgtable[tabIndex++],bSlash);
|
||||||
|
|
||||||
|
@ -1048,7 +1059,10 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
|
||||||
strgtable[tabIndex]=CoTaskMemAlloc(sizeof(WCHAR)*(j+1));
|
strgtable[tabIndex]=CoTaskMemAlloc(sizeof(WCHAR)*(j+1));
|
||||||
|
|
||||||
if (strgtable[tabIndex]==NULL)
|
if (strgtable[tabIndex]==NULL)
|
||||||
return E_OUTOFMEMORY;
|
{
|
||||||
|
ret = E_OUTOFMEMORY;
|
||||||
|
goto lend;
|
||||||
|
}
|
||||||
|
|
||||||
strcpyW(strgtable[tabIndex++],word);
|
strcpyW(strgtable[tabIndex++],word);
|
||||||
}
|
}
|
||||||
|
@ -1057,7 +1071,21 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
|
||||||
|
|
||||||
*stringTable=strgtable;
|
*stringTable=strgtable;
|
||||||
|
|
||||||
return tabIndex;
|
ret = tabIndex;
|
||||||
|
|
||||||
|
lend:
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
for (i = 0; i < tabIndex; i++)
|
||||||
|
CoTaskMemFree(strgtable[i]);
|
||||||
|
|
||||||
|
CoTaskMemFree(strgtable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (word)
|
||||||
|
CoTaskMemFree(word);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue