[PATCH 5/9] test: Fix memory leak in testParseXMLDocFromFile

John Ferlan posted 9 patches 4 years, 5 months ago
[PATCH 5/9] test: Fix memory leak in testParseXMLDocFromFile
Posted by John Ferlan 4 years, 5 months ago
Since ceb3255c, @absFile could be leaked if we jumped to error.

Found by Coverity.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/test/test_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 7a1db21718..993f405f3c 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -781,7 +781,7 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *file, const char *type)
 {
     xmlNodePtr ret = NULL;
     xmlDocPtr doc = NULL;
-    char *absFile = NULL;
+    g_autofree char *absFile = NULL;
     g_autofree char *relFile = NULL;
 
     if ((relFile = virXMLPropString(node, "file"))) {
-- 
2.25.4

Re: [PATCH 5/9] test: Fix memory leak in testParseXMLDocFromFile
Posted by Peter Krempa 4 years, 5 months ago
On Tue, Jun 16, 2020 at 08:07:06 -0400, John Ferlan wrote:
> Since ceb3255c, @absFile could be leaked if we jumped to error.

It's leaked even on success path.