summaryrefslogtreecommitdiffstats
path: root/libmount/src/optstr.c
diff options
context:
space:
mode:
authorNamhyung Kim2013-09-25 17:32:05 +0200
committerKarel Zak2013-09-26 09:35:02 +0200
commit0705e84a1327cc03eeae184a4a47edeea4675f93 (patch)
treeb517d608089214508f9c4c74198f2481bd7a3323 /libmount/src/optstr.c
parentlibmount: Free splitted optstr's when error occurred (diff)
downloadkernel-qcow2-util-linux-0705e84a1327cc03eeae184a4a47edeea4675f93.tar.gz
kernel-qcow2-util-linux-0705e84a1327cc03eeae184a4a47edeea4675f93.tar.xz
kernel-qcow2-util-linux-0705e84a1327cc03eeae184a4a47edeea4675f93.zip
libmount: Set each optstr's to NULL if failed
When mnt_split_optstr() failed in the middle, vfs, fs, user optstr's are freed but not reset. It can lead to double frees at the end of mnt_fs_{ap,pre}pend_options(). Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Diffstat (limited to 'libmount/src/optstr.c')
-rw-r--r--libmount/src/optstr.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index 2ad75d9aa..2cd55685e 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -567,12 +567,18 @@ int mnt_split_optstr(const char *optstr, char **user, char **vfs,
rc = __mnt_optstr_append_option(fs, name, namesz,
val, valsz);
if (rc) {
- if (vfs)
+ if (vfs) {
free(*vfs);
- if (fs)
+ *vfs = NULL;
+ }
+ if (fs) {
free(*fs);
- if (user)
+ *fs = NULL;
+ }
+ if (user) {
free(*user);
+ *user = NULL;
+ }
return rc;
}
}