[PATCH 2/4] libmount: Free splitted optstr's when error occurred

Namhyung Kim
2013-09-25T15:32:31Z

When strdup() failed, u, v and f optstr's should be freed.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
libmount/src/fs.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libmount/src/fs.c b/libmount/src/fs.c
index c95cdc7..e3a2e1a 100644
--- a/libmount/src/fs.c
+++ b/libmount/src/fs.c
@@ -774,8 +774,12 @@ int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr)
if (rc)
return rc;
n = strdup(optstr);
- if (!n)
+ if (!n) {
+ free(u);
+ free(v);
+ free(f);
return -ENOMEM;
+ }
}

free(fs->fs_optstr);
--
1.7.9.2