]> granicus.if.org Git - shadow/commitdiff
Fix a resource leak in libmis/idmapping.c
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 6 Aug 2015 05:10:13 +0000 (00:10 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 6 Aug 2015 05:10:13 +0000 (00:10 -0500)
Reported at https://alioth.debian.org/tracker/?func=detail&atid=411478&aid=315136&group_id=30580
by Alejandro Joya.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
libmisc/idmapping.c

index 714c29ebd9fd84d7d93d6831d399c60cebc5f420..34de3ce518d119b95ff6a662938c384c0ebfb332 100644 (file)
@@ -71,12 +71,18 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
        /* Gather up the ranges from the command line */
        mapping = mappings;
        for (idx = 0; idx < ranges; idx++, argidx += 3, mapping++) {
-               if (!getulong(argv[argidx + 0], &mapping->upper))
+               if (!getulong(argv[argidx + 0], &mapping->upper)) {
+                       free(mappings);
                        return NULL;
-               if (!getulong(argv[argidx + 1], &mapping->lower))
+               }
+               if (!getulong(argv[argidx + 1], &mapping->lower)) {
+                       free(mappings);
                        return NULL;
-               if (!getulong(argv[argidx + 2], &mapping->count))
+               }
+               if (!getulong(argv[argidx + 2], &mapping->count)) {
+                       free(mappings);
                        return NULL;
+               }
        }
        return mappings;
 }