Commit ed75b162 authored by Mario Sanchez Prada's avatar Mario Sanchez Prada

gunixmounts: Ensure that libmount's context gets freed on early returns

Otherwise, it will be leaked in case the relevant table (mtab, fstab)
could not be retrieved for some reason.

https://bugzilla.gnome.org/show_bug.cgi?id=769238
parent b28c76b0
...@@ -393,7 +393,7 @@ _g_get_unix_mounts (void) ...@@ -393,7 +393,7 @@ _g_get_unix_mounts (void)
ctxt = mnt_new_context (); ctxt = mnt_new_context ();
mnt_context_get_mtab (ctxt, &table); mnt_context_get_mtab (ctxt, &table);
if (!table) if (!table)
return NULL; goto out;
iter = mnt_new_iter (MNT_ITER_FORWARD); iter = mnt_new_iter (MNT_ITER_FORWARD);
while (mnt_table_next_fs (table, iter, &fs) == 0) while (mnt_table_next_fs (table, iter, &fs) == 0)
...@@ -425,8 +425,9 @@ _g_get_unix_mounts (void) ...@@ -425,8 +425,9 @@ _g_get_unix_mounts (void)
return_list = g_list_prepend (return_list, mount_entry); return_list = g_list_prepend (return_list, mount_entry);
} }
mnt_free_iter (iter); mnt_free_iter (iter);
out:
mnt_free_context (ctxt); mnt_free_context (ctxt);
return g_list_reverse (return_list); return g_list_reverse (return_list);
...@@ -876,7 +877,7 @@ _g_get_unix_mount_points (void) ...@@ -876,7 +877,7 @@ _g_get_unix_mount_points (void)
ctxt = mnt_new_context (); ctxt = mnt_new_context ();
mnt_context_get_fstab (ctxt, &table); mnt_context_get_fstab (ctxt, &table);
if (!table) if (!table)
return NULL; goto out;
iter = mnt_new_iter (MNT_ITER_FORWARD); iter = mnt_new_iter (MNT_ITER_FORWARD);
while (mnt_table_next_fs (table, iter, &fs) == 0) while (mnt_table_next_fs (table, iter, &fs) == 0)
...@@ -942,8 +943,9 @@ _g_get_unix_mount_points (void) ...@@ -942,8 +943,9 @@ _g_get_unix_mount_points (void)
return_list = g_list_prepend (return_list, mount_point); return_list = g_list_prepend (return_list, mount_point);
} }
mnt_free_iter (iter); mnt_free_iter (iter);
out:
mnt_free_context (ctxt); mnt_free_context (ctxt);
return g_list_reverse (return_list); return g_list_reverse (return_list);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment