[PATCH 6/6] virconf: Resolve a possible memory leak in virConfSetValue

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

 



Found this one by inspection... The API claims to "own" the input
value even in the case of error.  However, in the initial entry
to the API if the value exists, was STRING, but without a str value
it just returned without freeing the 'value' which it claims to now
own.  So I added the virConfFreeValue() call in order to resolve.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virconf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virconf.c b/src/util/virconf.c
index b1509fe..01e5a6a 100644
--- a/src/util/virconf.c
+++ b/src/util/virconf.c
@@ -887,8 +887,10 @@ virConfSetValue(virConfPtr conf,
 {
     virConfEntryPtr cur, prev = NULL;
 
-    if (value && value->type == VIR_CONF_STRING && value->str == NULL)
+    if (value && value->type == VIR_CONF_STRING && value->str == NULL) {
+        virConfFreeValue(value);
         return -1;
+    }
 
     cur = conf->entries;
     while (cur != NULL) {
-- 
2.1.0

--
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]