diff options
author | Namhyung Kim | 2013-09-25 17:32:05 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-26 09:35:02 +0200 |
commit | 0705e84a1327cc03eeae184a4a47edeea4675f93 (patch) | |
tree | b517d608089214508f9c4c74198f2481bd7a3323 /libmount/src/optstr.c | |
parent | libmount: Free splitted optstr's when error occurred (diff) | |
download | kernel-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.c | 12 |
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; } } |