Fix leak in ostree_repo_list_collection_refs

We need to have the g_auto(GLnxDirFdIterator) inside the loop, or
we don't correctly clean up when iterating several times.

Closes: #1700
Approved by: cgwalters
This commit is contained in:
Alexander Larsson 2018-08-13 17:44:27 +02:00 committed by Atomic Bot
parent 521e0ec3ac
commit 016cae1573
1 changed files with 2 additions and 1 deletions

View File

@ -1251,7 +1251,6 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
(GDestroyNotify) ostree_collection_ref_free, (GDestroyNotify) ostree_collection_ref_free,
g_free); g_free);
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
g_autoptr(GString) base_path = g_string_new (""); g_autoptr(GString) base_path = g_string_new ("");
const gchar *main_collection_id = ostree_repo_get_collection_id (self); const gchar *main_collection_id = ostree_repo_get_collection_id (self);
@ -1277,6 +1276,8 @@ ostree_repo_list_collection_refs (OstreeRepo *self,
{ {
const char *refs_dir = *iter; const char *refs_dir = *iter;
gboolean refs_dir_exists = FALSE; gboolean refs_dir_exists = FALSE;
g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
if (!ot_dfd_iter_init_allow_noent (self->repo_dir_fd, refs_dir, if (!ot_dfd_iter_init_allow_noent (self->repo_dir_fd, refs_dir,
&dfd_iter, &refs_dir_exists, error)) &dfd_iter, &refs_dir_exists, error))
return FALSE; return FALSE;