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

[libvirt] [PATCH] ebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end



Coverity spotted two missing uses of va_end:

>From 4baa4228a74f640fe789914bd034e4c5b805cdfb Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Tue, 18 May 2010 14:42:33 +0200
Subject: [PATCH] ebtablesAddRemoveRule, iptablesAddRemoveRule: don't skip va_end

* src/util/ebtables.c (ebtablesAddRemoveRule): Don't skip
va_end(args) on an error path.
* src/util/iptables.c (iptablesAddRemoveRule): Identical change.
---
 src/util/ebtables.c |    7 +++++--
 src/util/iptables.c |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index e2b9608..f707756 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -207,15 +207,18 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)

     if (!(argv[n++] = strdup(arg)))
         goto error;

     va_start(args, arg);

-    while ((s = va_arg(args, const char *)))
-        if (!(argv[n++] = strdup(s)))
+    while ((s = va_arg(args, const char *))) {
+        if (!(argv[n++] = strdup(s))) {
+            va_end(args);
             goto error;
+        }
+    }

     va_end(args);

     if (!(rule = virArgvToString(&argv[command_idx])))
         goto error;

diff --git a/src/util/iptables.c b/src/util/iptables.c
index 4f95a02..d06b857 100644
--- a/src/util/iptables.c
+++ b/src/util/iptables.c
@@ -134,15 +134,18 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)

     if (!(argv[n++] = strdup(arg)))
         goto error;

     va_start(args, arg);

-    while ((s = va_arg(args, const char *)))
-        if (!(argv[n++] = strdup(s)))
+    while ((s = va_arg(args, const char *))) {
+        if (!(argv[n++] = strdup(s))) {
+            va_end(args);
             goto error;
+        }
+    }

     va_end(args);

     if (virRun(argv, NULL) < 0) {
         retval = errno;
         goto error;
--
1.7.1.250.g7d1e8


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