[libvirt] [PATCH] virExecWithHook: avoid leak on OOM error path

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

 



>From ab102cf853e3b46bf10cf0faafa643a352ed8888 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Thu, 4 Feb 2010 12:25:34 +0100
Subject: [PATCH] virExecWithHook: avoid leak on OOM error path

* src/util/util.c (virExecWithHook): Free argv_str string before
returning upon failure to allocate space for environment.
---
 src/util/util.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 7e0cd50..a01fc45 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -625,18 +625,19 @@ virExecWithHook(virConnectPtr conn,
     char *envp_str;

     if ((argv_str = virArgvToString(argv)) == NULL) {
         virReportOOMError(conn);
         return -1;
     }

     if (envp) {
         if ((envp_str = virArgvToString(envp)) == NULL) {
+            VIR_FREE(argv_str);
             virReportOOMError(conn);
             return -1;
         }
         VIR_DEBUG("%s %s", envp_str, argv_str);
         VIR_FREE(envp_str);
     } else {
         VIR_DEBUG0(argv_str);
     }
     VIR_FREE(argv_str);
--
1.7.0.rc1.199.g9253a

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