summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian Behlendorf <behlendorf1@llnl.gov>2007-03-21 17:14:10 -0400
committerTheodore Ts'o <tytso@mit.edu>2007-03-21 17:14:10 -0400
commit61bf36ef2d322ccdc231557a6ee45c7569a507c5 (patch)
tree8649b006f2c0093f3eb6dfdfeecd12e0af511d9a /lib
parent2711ca1c2344b7a8d38e36508f3daae261da7a02 (diff)
downloade2fsprogs-61bf36ef2d322ccdc231557a6ee45c7569a507c5.tar.gz
[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>
Diffstat (limited to 'lib')
-rw-r--r--lib/e2p/ChangeLog3
-rw-r--r--lib/e2p/mntopts.c16
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog
index 0518b2a1..557bdfd8 100644
--- a/lib/e2p/ChangeLog
+++ b/lib/e2p/ChangeLog
@@ -1,6 +1,7 @@
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>
diff --git a/lib/e2p/mntopts.c b/lib/e2p/mntopts.c
index 6d0eca0a..4e50e9f9 100644
--- a/lib/e2p/mntopts.c
+++ b/lib/e2p/mntopts.c
@@ -98,6 +98,7 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
char *cp, *buf, *next;
int neg;
unsigned int mask;
+ int rc = 0;
buf = malloc(strlen(str)+1);
if (!buf)
@@ -120,10 +121,14 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
cp++;
break;
}
- if (e2p_string2mntopt(cp, &mask))
- return 1;
- if (ok && !(ok & mask))
- return 1;
+ if (e2p_string2mntopt(cp, &mask)) {
+ rc = 1;
+ break;
+ }
+ if (ok && !(ok & mask)) {
+ rc = 1;
+ break;
+ }
if (mask & EXT3_DEFM_JMODE)
*mntopts &= ~EXT3_DEFM_JMODE;
if (neg)
@@ -132,5 +137,6 @@ int e2p_edit_mntopts(const char *str, __u32 *mntopts, __u32 ok)
*mntopts |= mask;
cp = next ? next+1 : 0;
}
- return 0;
+ free(buf);
+ return rc;
}