ole32: Improve error handling in GetClassFile() (PVS-Studio).

This commit is contained in:
Nikolay Sivov 2015-03-20 09:49:56 +03:00 committed by Alexandre Julliard
parent f294ea8333
commit 853dc5ec2f
1 changed files with 8 additions and 11 deletions

View File

@ -1198,7 +1198,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
IStorage *pstg=0; IStorage *pstg=0;
HRESULT res; HRESULT res;
int nbElm, length, i; int nbElm, length, i;
LONG sizeProgId; LONG sizeProgId, ret;
LPOLESTR *pathDec=0,absFile=0,progId=0; LPOLESTR *pathDec=0,absFile=0,progId=0;
LPWSTR extension; LPWSTR extension;
static const WCHAR bkslashW[] = {'\\',0}; static const WCHAR bkslashW[] = {'\\',0};
@ -1264,26 +1264,23 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
return MK_E_INVALIDEXTENSION; return MK_E_INVALIDEXTENSION;
} }
res=RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId); ret = RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId);
/* get the progId associated to the extension */ /* get the progId associated to the extension */
progId = CoTaskMemAlloc(sizeProgId); progId = CoTaskMemAlloc(sizeProgId);
res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId); ret = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId);
if (!ret)
if (res==ERROR_SUCCESS)
/* return the clsid associated to the progId */ /* return the clsid associated to the progId */
res= CLSIDFromProgID(progId,pclsid); res = CLSIDFromProgID(progId,pclsid);
else
res = HRESULT_FROM_WIN32(ret);
for(i=0; pathDec[i]!=NULL;i++) for(i=0; pathDec[i]!=NULL;i++)
CoTaskMemFree(pathDec[i]); CoTaskMemFree(pathDec[i]);
CoTaskMemFree(pathDec); CoTaskMemFree(pathDec);
CoTaskMemFree(progId); CoTaskMemFree(progId);
return res != S_OK ? MK_E_INVALIDEXTENSION : res;
if (res==ERROR_SUCCESS)
return res;
return MK_E_INVALIDEXTENSION;
} }
/*********************************************************************** /***********************************************************************