[ASAN] lib: Squash various leaks in library and commandline
The pull one is the most likely to affect users. Otherwise mostly just cleaning up `-fsanitize=address`. Closes: #587 Approved by: jlebon
This commit is contained in:
parent
eb7ba645af
commit
49b8a72622
|
|
@ -632,6 +632,9 @@ _ostree_metalink_request_sync (OstreeMetalink *self,
|
|||
if (mainctx)
|
||||
g_main_context_pop_thread_default (mainctx);
|
||||
g_clear_object (&request.metalink);
|
||||
g_clear_pointer (&request.verification_sha256, g_free);
|
||||
g_clear_pointer (&request.verification_sha512, g_free);
|
||||
g_clear_pointer (&request.last_metalink_error, g_free);
|
||||
g_clear_pointer (&request.urls, g_ptr_array_unref);
|
||||
g_clear_pointer (&request.parser, g_markup_parse_context_free);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -943,7 +943,10 @@ ostree_repo_write_archive_to_mtree (OstreeRepo *self,
|
|||
ret = TRUE;
|
||||
out:
|
||||
if (a)
|
||||
{
|
||||
(void)archive_read_close (a);
|
||||
(void)archive_read_free (a);
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
|
|
|
|||
|
|
@ -1982,7 +1982,7 @@ _ostree_repo_remote_new_fetcher (OstreeRepo *self,
|
|||
g_autofree char *cookie_file = g_strdup_printf ("%s.cookies.txt",
|
||||
remote_name);
|
||||
|
||||
jar_path = g_build_filename (g_file_get_path (self->repodir), cookie_file,
|
||||
jar_path = g_build_filename (gs_file_get_path_cached (self->repodir), cookie_file,
|
||||
NULL);
|
||||
|
||||
if (g_file_test(jar_path, G_FILE_TEST_IS_REGULAR))
|
||||
|
|
@ -2061,7 +2061,7 @@ fetch_mirrorlist (OstreeFetcher *fetcher,
|
|||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
char **lines = NULL;
|
||||
g_auto(GStrv) lines = NULL;
|
||||
g_autofree char *contents = NULL;
|
||||
SoupURI *mirrorlist = NULL;
|
||||
g_autoptr(GPtrArray) ret_mirrorlist =
|
||||
|
|
@ -2367,7 +2367,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
|||
const char *dir_to_pull = NULL;
|
||||
g_autofree char **dirs_to_pull = NULL;
|
||||
g_autofree char **refs_to_fetch = NULL;
|
||||
char **override_commit_ids = NULL;
|
||||
g_autofree char **override_commit_ids = NULL;
|
||||
GSource *update_timeout = NULL;
|
||||
gboolean disable_static_deltas = FALSE;
|
||||
gboolean require_static_deltas = FALSE;
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ _ostree_delta_compute_similar_objects (OstreeRepo *repo,
|
|||
{
|
||||
gboolean ret = FALSE;
|
||||
g_autoptr(GHashTable) ret_modified_regfile_content =
|
||||
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_ptr_array_unref);
|
||||
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
g_autoptr(GPtrArray) from_sizes = NULL;
|
||||
g_autoptr(GPtrArray) to_sizes = NULL;
|
||||
guint i, j;
|
||||
|
|
|
|||
|
|
@ -880,7 +880,9 @@ _ostree_repo_static_delta_dump (OstreeRepo *self,
|
|||
OT_VARIANT_MAP_TRUSTED, &delta_superblock, error))
|
||||
goto out;
|
||||
|
||||
g_print ("%s\n", g_variant_print (delta_superblock, 1));
|
||||
{ g_autofree char *variant_string = g_variant_print (delta_superblock, 1);
|
||||
g_print ("%s\n", variant_string);
|
||||
}
|
||||
|
||||
g_print ("Delta: %s\n", delta_id);
|
||||
{ const char *endianness_description;
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ initable_init (GInitable *initable,
|
|||
g_autoptr(GFileInputStream) filein = NULL;
|
||||
g_autoptr(GDataInputStream) datain = NULL;
|
||||
gboolean enabled = FALSE;
|
||||
char *policytype = NULL;
|
||||
g_autofree char *policytype = NULL;
|
||||
const char *selinux_prefix = "SELINUX=";
|
||||
const char *selinuxtype_prefix = "SELINUXTYPE=";
|
||||
|
||||
|
|
@ -352,7 +352,7 @@ initable_init (GInitable *initable,
|
|||
goto out;
|
||||
}
|
||||
|
||||
self->selinux_policy_name = g_strdup (policytype);
|
||||
self->selinux_policy_name = g_steal_pointer (&policytype);
|
||||
self->selinux_policy_root = g_object_ref (etc_selinux_dir);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ prune_repo (OstreeRepo *repo,
|
|||
|
||||
if (freed_space > 0)
|
||||
{
|
||||
char *freed_space_str = g_format_size_full (freed_space, 0);
|
||||
g_autofree char *freed_space_str = g_format_size_full (freed_space, 0);
|
||||
g_print ("Freed objects: %s\n", freed_space_str);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ parse_refspec (OstreeSysrootUpgrader *self,
|
|||
csum = g_key_file_get_string (self->origin, "origin", "override-commit", NULL);
|
||||
if (csum != NULL && !ostree_validate_checksum_string (csum, error))
|
||||
goto out;
|
||||
g_clear_pointer (&self->override_csum, g_free);
|
||||
self->override_csum = g_steal_pointer (&csum);
|
||||
|
||||
ret = TRUE;
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
|
|||
g_autoptr(GFile) subtree = NULL;
|
||||
g_autofree char *commit = NULL;
|
||||
g_autoptr(GVariant) commit_data = NULL;
|
||||
struct archive *a;
|
||||
struct archive *a = NULL;
|
||||
OstreeRepoExportArchiveOptions opts = { 0, };
|
||||
|
||||
context = g_option_context_new ("COMMIT - Stream COMMIT to stdout in tar format");
|
||||
|
|
@ -154,6 +154,10 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
|
|||
|
||||
ret = TRUE;
|
||||
out:
|
||||
#ifdef HAVE_LIBARCHIVE
|
||||
if (a)
|
||||
archive_write_free (a);
|
||||
#endif
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **
|
|||
if (opt_add_tombstones)
|
||||
{
|
||||
GError *local_error = NULL;
|
||||
const char *parent = ostree_commit_get_parent (commit);
|
||||
g_autofree char *parent = ostree_commit_get_parent (commit);
|
||||
if (parent)
|
||||
{
|
||||
g_autoptr(GVariant) parent_commit = NULL;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable,
|
|||
value = argv[5];
|
||||
|
||||
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
|
||||
jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
|
||||
jar_path = g_build_filename (gs_file_get_path_cached (repo->repodir), cookie_file, NULL);
|
||||
|
||||
jar = soup_cookie_jar_text_new (jar_path, FALSE);
|
||||
|
||||
|
|
@ -80,5 +80,7 @@ ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable,
|
|||
/* jar takes ownership of cookie */
|
||||
soup_cookie_jar_add_cookie (jar, cookie);
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellabl
|
|||
cookie_name = argv[4];
|
||||
|
||||
cookie_file = g_strdup_printf ("%s.cookies.txt", remote_name);
|
||||
jar_path = g_build_filename (g_file_get_path (repo->repodir), cookie_file, NULL);
|
||||
jar_path = g_build_filename (gs_file_get_path_cached (repo->repodir), cookie_file, NULL);
|
||||
|
||||
jar = soup_cookie_jar_text_new (jar_path, FALSE);
|
||||
cookies = soup_cookie_jar_all_cookies (jar);
|
||||
|
|
@ -92,5 +92,7 @@ ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellabl
|
|||
if (!found)
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Cookie not found in jar");
|
||||
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return found;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue