]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: Set each optstr's to NULL if failed
authorNamhyung Kim <namhyung@gmail.com>
Wed, 25 Sep 2013 15:32:05 +0000 (00:32 +0900)
committerKarel Zak <kzak@redhat.com>
Thu, 26 Sep 2013 07:35:02 +0000 (09:35 +0200)
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>
libmount/src/optstr.c

index 2ad75d9aac08b28d5d59ad44548b0ee979161140..2cd55685e1378c3f617bdfee02ab3667d0d80a30 100644 (file)
@@ -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;
                }
        }