core: Add valgrind framework, plug various memory leaks
This commit is contained in:
1 parent
7ce587da30
commit
8d926c3e36
13 files changed
+252
-47
No files matched your search
@@ -441,18 +441,18 @@ ostree_content_stream_parse (GInputStream *input,
|
||||
if (ret_file_info)
|
||||
g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8);
|
||||
|
||||
if (g_file_info_get_file_type (ret_file_info) != G_FILE_TYPE_REGULAR)
|
||||
if (g_file_info_get_file_type (ret_file_info) == G_FILE_TYPE_REGULAR
|
||||
&& out_input)
|
||||
{
|
||||
g_clear_object (&ret_input);
|
||||
/* Give the input stream at its current position as return value;
|
||||
* assuming the caller doesn't seek, this should be fine. We might
|
||||
* want to wrap it though in a non-seekable stream.
|
||||
**/
|
||||
ret_input = g_object_ref (input);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
/* Give the input stream at its current position as return value;
|
||||
* assuming the caller doesn't seek, this should be fine. We might
|
||||
* want to wrap it though in a non-seekable stream.
|
||||
**/
|
||||
g_object_ref (input);
|
||||
ot_transfer_out_value (out_input, &input);
|
||||
ot_transfer_out_value (out_input, &ret_input);
|
||||
ot_transfer_out_value (out_file_info, &ret_file_info);
|
||||
ot_transfer_out_value (out_xattrs, &ret_xattrs);
|
||||
out:
|
||||
@@ -1835,6 +1835,7 @@ ostree_validate_structureof_pack_superindex (GVariant *superindex,
|
||||
goto out;
|
||||
}
|
||||
csum_v = NULL;
|
||||
bloom = NULL;
|
||||
|
||||
g_variant_get_child (superindex, 3, "a(ayay)", &content_iter);
|
||||
while (g_variant_iter_loop (content_iter, "(@ay@ay)",
|
||||
@@ -1844,6 +1845,7 @@ ostree_validate_structureof_pack_superindex (GVariant *superindex,
|
||||
goto out;
|
||||
}
|
||||
csum_v = NULL;
|
||||
bloom = NULL;
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
|
||||
@@ -65,6 +65,7 @@ ostree_repo_file_finalize (GObject *object)
|
||||
g_free (self->tree_contents_checksum);
|
||||
g_free (self->tree_metadata_checksum);
|
||||
g_free (self->commit);
|
||||
g_clear_error (&self->commit_resolve_error);
|
||||
g_free (self->name);
|
||||
|
||||
G_OBJECT_CLASS (ostree_repo_file_parent_class)->finalize (object);
|
||||
@@ -400,6 +401,8 @@ ostree_repo_file_get_checksum (OstreeRepoFile *self)
|
||||
|
||||
self->cached_file_checksum = ostree_checksum_from_bytes_v (csum_bytes);
|
||||
|
||||
g_variant_unref (csum_bytes);
|
||||
|
||||
return self->cached_file_checksum;
|
||||
}
|
||||
|
||||
@@ -721,7 +724,7 @@ bsearch_in_file_variant (GVariant *variant,
|
||||
imin = 0;
|
||||
while (imax >= imin)
|
||||
{
|
||||
GVariant *child;
|
||||
ot_lvariant GVariant *child = NULL;
|
||||
const char *cur;
|
||||
int cmp;
|
||||
|
||||
@@ -741,11 +744,9 @@ bsearch_in_file_variant (GVariant *variant,
|
||||
}
|
||||
else
|
||||
{
|
||||
ot_clear_gvariant (&child);
|
||||
*out_pos = imid;
|
||||
return TRUE;
|
||||
}
|
||||
ot_clear_gvariant (&child);
|
||||
}
|
||||
|
||||
*out_pos = imid;
|
||||
|
||||
@@ -265,13 +265,12 @@ parse_rev_file (OstreeRepo *self,
|
||||
|
||||
if (g_str_has_prefix (rev, "ref: "))
|
||||
{
|
||||
GFile *ref;
|
||||
ot_lobj GFile *ref = NULL;
|
||||
char *ref_sha256;
|
||||
gboolean subret;
|
||||
|
||||
ref = g_file_resolve_relative_path (priv->local_heads_dir, rev + 5);
|
||||
subret = parse_rev_file (self, ref, &ref_sha256, error);
|
||||
g_clear_object (&ref);
|
||||
|
||||
if (!subret)
|
||||
{
|
||||
@@ -3025,7 +3024,7 @@ list_loose_object_dir (OstreeRepo *self,
|
||||
value = g_variant_new ("(b@as)",
|
||||
TRUE, g_variant_new_strv (NULL, 0));
|
||||
/* transfer ownership */
|
||||
g_hash_table_replace (inout_objects, g_variant_ref_sink (key),
|
||||
g_hash_table_replace (inout_objects, key,
|
||||
g_variant_ref_sink (value));
|
||||
}
|
||||
loop_next:
|
||||
@@ -3870,7 +3869,7 @@ checkout_one_file (OstreeRepo *self,
|
||||
|
||||
if (link_cache)
|
||||
{
|
||||
ot_lobj GFile *parent;
|
||||
ot_lobj GFile *parent = NULL;
|
||||
g_assert (possible_loose_path);
|
||||
|
||||
parent = g_file_get_parent (possible_loose_path);
|
||||
@@ -3907,8 +3906,6 @@ ostree_repo_checkout_tree (OstreeRepo *self,
|
||||
ot_lobj GFileInfo *file_info = NULL;
|
||||
ot_lvariant GVariant *xattrs = NULL;
|
||||
ot_lobj GFileEnumerator *dir_enum = NULL;
|
||||
ot_lobj GFile *src_child = NULL;
|
||||
ot_lobj GFile *dest_path = NULL;
|
||||
|
||||
if (!ostree_repo_file_get_xattrs (source, &xattrs, NULL, error))
|
||||
goto out;
|
||||
@@ -3931,14 +3928,13 @@ ostree_repo_checkout_tree (OstreeRepo *self,
|
||||
{
|
||||
const char *name;
|
||||
guint32 type;
|
||||
ot_lobj GFile *dest_path = NULL;
|
||||
ot_lobj GFile *src_child = NULL;
|
||||
|
||||
name = g_file_info_get_attribute_byte_string (file_info, "standard::name");
|
||||
type = g_file_info_get_attribute_uint32 (file_info, "standard::type");
|
||||
|
||||
g_clear_object (&dest_path);
|
||||
dest_path = g_file_get_child (destination, name);
|
||||
|
||||
g_clear_object (&src_child);
|
||||
src_child = g_file_get_child ((GFile*)source, name);
|
||||
|
||||
if (type == G_FILE_TYPE_DIRECTORY)
|
||||
|
||||
@@ -280,6 +280,7 @@ fetch_one_pack_file (OtPullData *pull_data,
|
||||
goto out;
|
||||
}
|
||||
|
||||
g_clear_object (&ret_cached_path);
|
||||
if (!ostree_repo_get_cached_remote_pack_data (pull_data->repo, pull_data->remote_name,
|
||||
pack_checksum, is_meta, &ret_cached_path,
|
||||
cancellable, error))
|
||||
@@ -1038,6 +1039,7 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
gpointer key, value;
|
||||
int i;
|
||||
GCancellable *cancellable = NULL;
|
||||
ot_lfree char *tmpstr = NULL;
|
||||
ot_lobj OstreeRepo *repo = NULL;
|
||||
ot_lfree char *path = NULL;
|
||||
ot_lfree char *baseurl = NULL;
|
||||
@@ -1081,8 +1083,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
|
||||
config = ostree_repo_get_config (repo);
|
||||
|
||||
key = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
|
||||
baseurl = g_key_file_get_string (config, key, "url", error);
|
||||
tmpstr = g_strdup_printf ("remote \"%s\"", pull_data->remote_name);
|
||||
baseurl = g_key_file_get_string (config, tmpstr, "url", error);
|
||||
if (!baseurl)
|
||||
goto out;
|
||||
pull_data->base_uri = soup_uri_new (baseurl);
|
||||
@@ -1248,8 +1250,10 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
g_clear_object (&pull_data->session);
|
||||
g_free (pull_data->remote_name);
|
||||
if (pull_data->base_uri)
|
||||
soup_uri_free (pull_data->base_uri);
|
||||
ot_clear_hashtable (&pull_data->file_checksums_to_fetch);
|
||||
ot_clear_ptrarray (&pull_data->cached_meta_pack_indexes);
|
||||
ot_clear_ptrarray (&pull_data->cached_data_pack_indexes);
|
||||
if (summary_uri)
|
||||
|
||||
@@ -188,7 +188,6 @@ ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
NULL, error);
|
||||
if (!metadata)
|
||||
goto out;
|
||||
g_variant_ref_sink (metadata);
|
||||
}
|
||||
else if (metadata_bin_path)
|
||||
{
|
||||
@@ -210,7 +209,7 @@ ostree_builtin_commit (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
{
|
||||
const char *s;
|
||||
const char *eq;
|
||||
char *key;
|
||||
ot_lfree char *key = NULL;
|
||||
|
||||
s = *iter;
|
||||
|
||||
|
||||
@@ -362,6 +362,7 @@ diff_dirs (GFile *a,
|
||||
if (!dir_enum)
|
||||
goto out;
|
||||
|
||||
g_clear_object (&child_b_info);
|
||||
while ((child_b_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp_error)) != NULL)
|
||||
{
|
||||
const char *name;
|
||||
@@ -397,6 +398,7 @@ diff_dirs (GFile *a,
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
g_clear_object (&child_b_info);
|
||||
}
|
||||
if (temp_error != NULL)
|
||||
{
|
||||
@@ -498,5 +500,7 @@ ostree_builtin_diff (int argc, char **argv, GFile *repo_path, GError **error)
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
}
|
||||
@@ -737,7 +737,7 @@ do_stats_gather_loose (OtRepackData *data,
|
||||
OstreeObjectType objtype;
|
||||
gboolean is_loose;
|
||||
gboolean is_packed;
|
||||
GVariant *pack_array;
|
||||
ot_lvariant GVariant *pack_array = NULL;
|
||||
|
||||
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
|
||||
|
||||
|
||||
@@ -206,6 +206,10 @@ ostree_builtin_pull_local (int argc, char **argv, GFile *repo_path, GError **err
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
if (data.src_repo)
|
||||
g_object_unref (data.src_repo);
|
||||
if (data.dest_repo)
|
||||
g_object_unref (data.dest_repo);
|
||||
if (context)
|
||||
g_option_context_free (context);
|
||||
return ret;
|
||||
|
||||
Reference in new issue
Block a user