diff --git a/src/libostree/ostree-repo-static-delta-core.c b/src/libostree/ostree-repo-static-delta-core.c index dc57a2f03d..66f2740f01 100644 --- a/src/libostree/ostree-repo-static-delta-core.c +++ b/src/libostree/ostree-repo-static-delta-core.c @@ -409,7 +409,15 @@ ostree_repo_static_delta_execute_offline_with_signature (OstreeRepo *self, GFile return glnx_throw_errno_prefix (error, "openat(O_DIRECTORY)"); else { - g_autofree char *dir = dirname (g_strdup (dir_or_file_path)); + g_autofree char *dir = ""; + if (dir_or_file_path[strlen (dir_or_file_path) - 1] == G_DIR_SEPARATOR) + { + g_autofree char *modifed_dir = g_strdup (dir_or_file_path); + modifed_dir[strlen (modifed_dir) - 1] = '\0'; + dir = g_path_get_dirname (modifed_dir); + } + else + dir = g_path_get_dirname (dir_or_file_path); basename = g_path_get_basename (dir_or_file_path); if (!glnx_opendirat (AT_FDCWD, dir, TRUE, &dfd, error))