StopService() unconditionally calls CloseServiceHandle() on both
the service and manager handles in the cleanup path, even when
OpenSCManager() or OpenService() failed and the handles are NULL.

Fixes: 917ebcb17027 ("qga-win: Fix QGA VSS Provider service stop failure")
Signed-off-by: Marc-André Lureau <[email protected]>
---
 qga/vss-win32/install.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index 12b045e2074f..9e8db79c122c 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -597,8 +597,12 @@ STDAPI StopService(void)
     }
 
 out:
-    CloseServiceHandle(service);
-    CloseServiceHandle(manager);
+    if (service) {
+        CloseServiceHandle(service);
+    }
+    if (manager) {
+        CloseServiceHandle(manager);
+    }
     qga_debug_end;
     return hr;
 }

-- 
2.55.0.543.g5ebe2ebe4ea8


Reply via email to