Declare locals in correct order.
authorDavid Mitchell <dmitchell@logos.com>
Thu, 16 Jul 2015 15:46:48 +0000 (08:46 -0700)
committerDavid Mitchell <dmitchell@logos.com>
Thu, 16 Jul 2015 15:55:50 +0000 (08:55 -0700)
The order of declaration doesn't matter when the call to CreateInstance
succeeds because the call to unload the DLL is suppressed. However, if
CreateInstance fails, we do unload the DLL, and this needs to happen after the
call to Release on the class factory.

src/utilcode/util.cpp

index 30181da..8b1fa55 100644 (file)
@@ -263,8 +263,8 @@ HRESULT FakeCoCreateInstanceEx(REFCLSID       rclsid,
     HRESULT hr = S_OK;
 
     // Call the function to get a class factory for the rclsid passed in.
-    ReleaseHolder<IClassFactory> classFactory;
     HModuleHolder hDll;
+    ReleaseHolder<IClassFactory> classFactory;
     IfFailRet(FakeCoCallDllGetClassObject(rclsid, wszDllPath, _IID_IClassFactory, (void**)&classFactory, &hDll));
 
     // Ask the class factory to create an instance of the