[netcf-devel] [PATCH 4/4] * src/dutil_linux.c (bridge_nf_call_iptables): fix memory leak

David Lutterkort lutter at redhat.com
Thu Oct 15 15:24:00 UTC 2009


Fixes BZ 528927
---
 src/dutil_linux.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/dutil_linux.c b/src/dutil_linux.c
index b728f5f..e5b1dc7 100644
--- a/src/dutil_linux.c
+++ b/src/dutil_linux.c
@@ -157,6 +157,7 @@ bool bridge_nf_call_iptables(struct netcf *ncf) {
     char *path = NULL;
     FILE *proc = NULL;
     int r, c;
+    bool result = false;
 
     r = xasprintf(&path, "%s%s", ncf->root, proc_bridge_nf_call_iptables);
     ERR_NOMEM(r < 0, ncf);
@@ -167,13 +168,13 @@ bool bridge_nf_call_iptables(struct netcf *ncf) {
     c = fgetc(proc);
     ERR_THROW(c == EOF, ncf, EFILE, "nothing to read from %s: %s",
               path, strerror(errno));
-    fclose(proc);
-    return c == '1';
+    result = (c == '1');
+
  error:
     FREE(path);
     if (proc != NULL)
         fclose(proc);
-    return false;
+    return result;
 }
 
 /*
-- 
1.6.2.5



More information about the netcf-devel mailing list