From: Marc-AndrĂ© Lureau <[email protected]>

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]>
Reviewed-by: Kostiantyn Kostiuk <[email protected]>
Link: 
https://lore.kernel.org/qemu-devel/[email protected]
Signed-off-by: Kostiantyn Kostiuk <[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 52176d7512..b9269acb5b 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


Reply via email to