From: Brian Behlendorf Date: Wed, 21 Mar 2007 20:48:47 +0000 (-0400) Subject: [COVERITY] Fix memory leak in libe2p (e2p_edit_feature) X-Git-Tag: E2FSPROGS-1_40~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2711ca1c2344b7a8d38e36508f3daae261da7a02;p=thirdparty%2Fe2fsprogs.git [COVERITY] Fix memory leak in libe2p (e2p_edit_feature) Coverity ID: 15: Resource Leak Signed-off-by: Brian Behlendorf Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog index c5f08661c..0518b2a1a 100644 --- a/lib/e2p/ChangeLog +++ b/lib/e2p/ChangeLog @@ -1,3 +1,7 @@ +2007-03-21 Theodore Tso + + * feature.c (e2p_edit_feature): Fix memory leak. + 2006-11-12 Theodore Tso * feature.c: Add support for printing the huge_file, gdt_checksum, diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c index ea0c6fa01..fe7e65a85 100644 --- a/lib/e2p/feature.c +++ b/lib/e2p/feature.c @@ -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; } -