Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/commit: fix using uninitialized var #1216

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2496,23 +2496,16 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
GCancellable *cancellable,
GError **error)
{
g_autoptr(GFile) child = NULL;
g_autoptr(GFileInfo) modified_info = NULL;
g_autoptr(OstreeMutableTree) child_mtree = NULL;
g_autofree char *child_relpath = NULL;
const char *name;
GFileType file_type;
OstreeRepoCommitFilterResult filter_result;

g_assert (dir_enum != NULL || dfd_iter != NULL);

name = g_file_info_get_name (child_info);
const char *name = g_file_info_get_name (child_info);
g_ptr_array_add (path, (char*)name);

if (modifier != NULL)
child_relpath = ptrarray_path_join (path);
g_autofree char *child_relpath = ptrarray_path_join (path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC I did this intentionally to avoid the malloc if we didn't have a commit modifier. But eh, perhaps down the line we can tweak this to use a scratch GString buffer like we do in other places.


filter_result = _ostree_repo_commit_modifier_apply (self, modifier, child_relpath, child_info, &modified_info);
g_autoptr(GFileInfo) modified_info = NULL;
OstreeRepoCommitFilterResult filter_result =
_ostree_repo_commit_modifier_apply (self, modifier, child_relpath, child_info, &modified_info);

if (filter_result != OSTREE_REPO_COMMIT_FILTER_ALLOW)
{
Expand All @@ -2521,23 +2514,24 @@ write_directory_content_to_mtree_internal (OstreeRepo *self,
return TRUE;
}

file_type = g_file_info_get_file_type (child_info);
GFileType file_type = g_file_info_get_file_type (child_info);
switch (file_type)
{
case G_FILE_TYPE_DIRECTORY:
case G_FILE_TYPE_SYMBOLIC_LINK:
case G_FILE_TYPE_REGULAR:
break;
default:
return glnx_throw (error, "Unsupported file type: '%s'",
gs_file_get_path_cached (child));
return glnx_throw (error, "Unsupported file type for file: '%s'", child_relpath);
}

g_autoptr(GFile) child = NULL;
if (dir_enum != NULL)
child = g_file_enumerator_get_child (dir_enum, child_info);

if (file_type == G_FILE_TYPE_DIRECTORY)
{
g_autoptr(OstreeMutableTree) child_mtree = NULL;
if (!ostree_mutable_tree_ensure_dir (mtree, name, &child_mtree, error))
return FALSE;

Expand Down