mirror of https://github.com/vitalif/e2fsprogs
[COVERITY] Fix memory leak in libe2p (e2p_edit_mntopts)
Need to free memory allocated to buf. Coverity ID: 17: Resource Leak Coverity ID: 18: Resource Leak Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>bitmap-optimize
parent
2711ca1c23
commit
61bf36ef2d
|
@ -1,6 +1,7 @@
|
||||||
2007-03-21 Theodore Tso <tytso@mit.edu>
|
2007-03-21 Theodore Tso <tytso@mit.edu>
|
||||||
|
|
||||||
* feature.c (e2p_edit_feature): Fix memory leak.
|
* feature.c (e2p_edit_feature), mntopts.c (e2p_edit_mntopts): Fix
|
||||||
|
memory leak.
|
||||||
|
|
||||||
2006-11-12 Theodore Tso <tytso@mit.edu>
|
2006-11-12 Theodore Tso <tytso@mit.edu>
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
|
||||||
char *cp, *buf, *next;
|
char *cp, *buf, *next;
|
||||||
int neg;
|
int neg;
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
buf = malloc(strlen(str)+1);
|
buf = malloc(strlen(str)+1);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
@ -120,10 +121,14 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
|
||||||
cp++;
|
cp++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (e2p_string2mntopt(cp, &mask))
|
if (e2p_string2mntopt(cp, &mask)) {
|
||||||
return 1;
|
rc = 1;
|
||||||
if (ok && !(ok & mask))
|
break;
|
||||||
return 1;
|
}
|
||||||
|
if (ok && !(ok & mask)) {
|
||||||
|
rc = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (mask & EXT3_DEFM_JMODE)
|
if (mask & EXT3_DEFM_JMODE)
|
||||||
*mntopts &= ~EXT3_DEFM_JMODE;
|
*mntopts &= ~EXT3_DEFM_JMODE;
|
||||||
if (neg)
|
if (neg)
|
||||||
|
@ -132,5 +137,6 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
|
||||||
*mntopts |= mask;
|
*mntopts |= mask;
|
||||||
cp = next ? next+1 : 0;
|
cp = next ? next+1 : 0;
|
||||||
}
|
}
|
||||||
return 0;
|
free(buf);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue