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

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 20 08:43:19 CDT 2015


Module: wine
Branch: master
Commit: 853dc5ec2f474b892ff9d83efcf892345b0a9664
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=853dc5ec2f474b892ff9d83efcf892345b0a9664

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Fri Mar 20 09:49:56 2015 +0300

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

---

 dlls/ole32/moniker.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/dlls/ole32/moniker.c b/dlls/ole32/moniker.c
index d694df9..5c46de9 100644
--- a/dlls/ole32/moniker.c
+++ b/dlls/ole32/moniker.c
@@ -1198,7 +1198,7 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
     IStorage *pstg=0;
     HRESULT res;
     int nbElm, length, i;
-    LONG sizeProgId;
+    LONG sizeProgId, ret;
     LPOLESTR *pathDec=0,absFile=0,progId=0;
     LPWSTR extension;
     static const WCHAR bkslashW[] = {'\\',0};
@@ -1264,26 +1264,23 @@ HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
         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 */
     progId = CoTaskMemAlloc(sizeProgId);
-    res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId);
-
-    if (res==ERROR_SUCCESS)
+    ret = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId);
+    if (!ret)
         /* 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++)
         CoTaskMemFree(pathDec[i]);
     CoTaskMemFree(pathDec);
 
     CoTaskMemFree(progId);
-
-    if (res==ERROR_SUCCESS)
-        return res;
-
-    return MK_E_INVALIDEXTENSION;
+    return res != S_OK ? MK_E_INVALIDEXTENSION : res;
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list