Util-Linux package development
 help / color / mirror / Atom feed
From: Andreas Henriksson <andreas@fatal.se>
To: util-linux@vger.kernel.org
Cc: Andreas Henriksson <andreas@fatal.se>
Subject: [PATCH 1/2] lib/strutil: fix parse_switch resource leak [coverity scan]
Date: Tue, 25 Aug 2015 18:27:40 +0200	[thread overview]
Message-ID: <1440520061-23922-1-git-send-email-andreas@fatal.se> (raw)

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
 lib/strutils.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/strutils.c b/lib/strutils.c
index b033f75..30dc090 100644
--- a/lib/strutils.c
+++ b/lib/strutils.c
@@ -198,10 +198,13 @@ int parse_switch(const char *arg, const char *errmesg, ...)
 		if (!b)
 			break;
 
-		if (strcmp(arg, a) == 0)
+		if (strcmp(arg, a) == 0) {
+			va_end(ap);
 			return 1;
-		else if (strcmp(arg, b) == 0)
+		} else if (strcmp(arg, b) == 0) {
+			va_end(ap);
 			return 0;
+		}
 	} while (1);
 	va_end(ap);
 
-- 
2.1.4


             reply	other threads:[~2015-08-25 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 16:27 Andreas Henriksson [this message]
2015-08-25 16:27 ` [PATCH 2/2] lsblk: fix resource leak [coverity scan] Andreas Henriksson
2015-08-31  8:11 ` [PATCH 1/2] lib/strutil: fix parse_switch " Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440520061-23922-1-git-send-email-andreas@fatal.se \
    --to=andreas@fatal.se \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox