]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: initialize *root to NULL in mnt_table_get_root_fs
authorThomas Bächler <thomas@archlinux.org>
Sun, 16 Feb 2014 13:58:06 +0000 (14:58 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 17 Feb 2014 12:36:47 +0000 (13:36 +0100)
mnt_table_get_root_fs only works when *root is set to NULL. This
is not only undocumented, but also unintuitive. Fix it by initializing
*root inside mnt_table_get_root_fs.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/tab.c

index 8ae49c8dfe4767d322f25b227eb0e84833d9f131..4c2f8a4ace5b5013c4b0adb450b1c60c50d7c042 100644 (file)
@@ -510,6 +510,8 @@ int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root)
 
        DBG(TAB, mnt_debug_h(tb, "lookup root fs"));
 
+       *root = NULL;
+
        mnt_reset_iter(&itr, MNT_ITER_FORWARD);
        while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
                int id = mnt_fs_get_parent_id(fs);