]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
[COVERITY] Fix memory leak in libe2p (e2p_edit_feature)
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 21 Mar 2007 20:48:47 +0000 (16:48 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 21 Mar 2007 20:48:47 +0000 (16:48 -0400)
Coverity ID: 15: Resource Leak

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/e2p/ChangeLog
lib/e2p/feature.c

index c5f08661c5ba52c1f71627b735c7fab7c64b0c68..0518b2a1adc0f22a443ef00c7bb708dc76e84af0 100644 (file)
@@ -1,3 +1,7 @@
+2007-03-21  Theodore Tso  <tytso@mit.edu>
+
+       * feature.c (e2p_edit_feature): Fix memory leak.
+
 2006-11-12  Theodore Tso  <tytso@mit.edu>
 
        * feature.c: Add support for printing the huge_file, gdt_checksum,
index ea0c6fa013974198e14672085828851187ef7db2..fe7e65a8592e443231481b060c2b56722f0131fe 100644 (file)
@@ -165,10 +165,11 @@ static char *skip_over_word(char *cp)
  */
 int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
 {
-       char    *cp, *buf, *next;
-       int     neg;
+       char            *cp, *buf, *next;
+       int             neg;
        unsigned int    mask;
        int             compat_type;
+       int             rc = 0;
 
        buf = malloc(strlen(str)+1);
        if (!buf)
@@ -200,15 +201,19 @@ int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
                        cp++;
                        break;
                }
-               if (e2p_string2feature(cp, &compat_type, &mask))
-                       return 1;
-               if (ok_array && !(ok_array[compat_type] & mask))
-                       return 1;
+               if (e2p_string2feature(cp, &compat_type, &mask)) {
+                       rc = 1;
+                       break;
+               }
+               if (ok_array && !(ok_array[compat_type] & mask)) {
+                       rc = 1;
+                       break;
+               }
                if (neg)
                        compat_array[compat_type] &= ~mask;
                else
                        compat_array[compat_type] |= mask;
        }
-       return 0;
+       free(buf);
+       return rc;
 }
-