[PATCH 4/7] util: Resolve memory leaks in virLogParse{Output|Filter}

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

 



In both virLogParseOutput and virLogParseFilter, rather than returning
NULL, goto cleanup since it's possible that for each the first condition
passes, but the || condition doesn't and thus we leak memory.

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

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 14ee701..52b0eea 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1466,7 +1466,7 @@ virLogParseOutput(const char *src)
     if (!(tokens = virStringSplitCount(src, ":", 0, &count)) || count < 2) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("Malformed format for output '%s'"), src);
-        return NULL;
+        goto cleanup;
     }
 
     if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 ||
@@ -1575,7 +1575,7 @@ virLogParseFilter(const char *src)
     if (!(tokens = virStringSplitCount(src, ":", 0, &count)) || count != 2) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("Malformed format for filter '%s'"), src);
-        return NULL;
+        goto cleanup;
     }
 
     if (virStrToLong_uip(tokens[0], NULL, 10, &prio) < 0 ||
-- 
2.7.4

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