[PATCH 09/23] Fix leak of comment string if virConfAddEntry fails on OOM

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The code parsing comments in config files called virConfAddEntry
but did not check for failure. This caused the comment string to
leak on OOM.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/util/virconf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/util/virconf.c b/src/util/virconf.c
index 9952f3f..e882d15 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -589,7 +589,10 @@ virConfParseComment(virConfParserCtxtPtr ctxt)
     while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
     if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0)
         return -1;
-    virConfAddEntry(ctxt->conf, NULL, NULL, comm);
+    if (virConfAddEntry(ctxt->conf, NULL, NULL, comm) == NULL) {
+        VIR_FREE(comm);
+        return -1;
+    }
     return 0;
 }
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]