@@ -810,14 +810,30 @@ class ExecutionTest {
810810 // The WARP_DLL runtime parameter can be used to specify a specific DLL to
811811 // load. To force this to be used, we make sure that this DLL is loaded
812812 // before attempting to create the device.
813- HMODULE ExplicitlyLoadedWarpDll = NULL;
813+
814+ struct WarpDll {
815+ HMODULE Module = NULL;
816+
817+ ~WarpDll() {
818+ Close();
819+ }
820+
821+ void Close() {
822+ if (Module) {
823+ FreeLibrary(Module);
824+ Module = NULL;
825+ }
826+ }
827+ };
828+
829+ WarpDll ExplicitlyLoadedWarpDll;
814830 WEX::Common::String WarpDllPath;
815831 if (SUCCEEDED(WEX::TestExecution::RuntimeParameters::TryGetValue(
816832 L"WARP_DLL", WarpDllPath))) {
817833 WEX::Logging::Log::Comment(WEX::Common::String().Format(
818834 L"WARP_DLL requested: %ls", (const wchar_t *)WarpDllPath));
819- ExplicitlyLoadedWarpDll = LoadLibraryExW(WarpDllPath, NULL, 0);
820- VERIFY_WIN32_BOOL_SUCCEEDED(!!ExplicitlyLoadedWarpDll);
835+ ExplicitlyLoadedWarpDll.Module = LoadLibraryExW(WarpDllPath, NULL, 0);
836+ VERIFY_WIN32_BOOL_SUCCEEDED(!!ExplicitlyLoadedWarpDll.Module );
821837 }
822838
823839 // Create the WARP device
@@ -837,10 +853,7 @@ class ExecutionTest {
837853
838854 // Now that the WARP device is created we can release our reference to the
839855 // warp dll.
840- if (ExplicitlyLoadedWarpDll) {
841- FreeLibrary(ExplicitlyLoadedWarpDll);
842- ExplicitlyLoadedWarpDll = NULL;
843- }
856+ ExplicitlyLoadedWarpDll.Close();
844857
845858 // Log the actual version of WARP that's loaded so we can be sure that
846859 // we're using the version we think.
0 commit comments