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

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



>From ab102cf853e3b46bf10cf0faafa643a352ed8888 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
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


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