]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/strutil: fix parse_switch resource leak [coverity scan]
authorAndreas Henriksson <andreas@fatal.se>
Tue, 25 Aug 2015 16:27:40 +0000 (18:27 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 31 Aug 2015 08:09:43 +0000 (10:09 +0200)
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
lib/strutils.c

index b033f7592b4638ef5be91fb152a909ecf912d65b..30dc090b4f2cc5ccadc1ab9a80d303e319fa1bd6 100644 (file)
@@ -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);