bstrWriterName is obtained from GetIdentity in the outer writer loop,
but freed inside the inner component loop. When a writer has multiple
components, the second and subsequent iterations operate with a NULL
bstrWriterName. If an error occurs in those iterations, the error
message passes NULL

Move SysFreeString(bstrWriterName) to the end of the outer loop where
it belongs.

Fixes: b39297aedfab ("qemu-ga: Add Windows VSS provider and requester as DLL")
Signed-off-by: Marc-André Lureau <[email protected]>
---
 qga/vss-win32/requester.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp
index 52176d751274..b9269acb5b8e 100644
--- a/qga/vss-win32/requester.cpp
+++ b/qga/vss-win32/requester.cpp
@@ -230,11 +230,11 @@ static void AddComponents(ErrorSet *errset)
                     goto out;
                 }
             }
-            SysFreeString(bstrWriterName);
-            bstrWriterName = NULL;
             pComponent->FreeComponentInfo(info);
             info = NULL;
         }
+        SysFreeString(bstrWriterName);
+        bstrWriterName = NULL;
     }
 out:
     if (bstrWriterName) {

-- 
2.55.0.543.g5ebe2ebe4ea8


Reply via email to