d/p/*.patch: import more memory leak fixes from upstream
This commit is contained in:
parent
9dd341b8b4
commit
0e2a6b4779
|
|
@ -12,6 +12,7 @@ ostree (2016.14-2) UNRELEASED; urgency=medium
|
|||
replace d/p/debian/Terminate-individual-tests-after-half-an-hour.patch
|
||||
with the version that I sent upstream, which uses SIGABRT and
|
||||
terminates the tests sooner
|
||||
* d/p/*.patch: import more memory leak fixes from upstream
|
||||
|
||||
-- Simon McVittie <smcv@debian.org> Thu, 01 Dec 2016 12:29:00 +0000
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 22:02:42 -0500
|
||||
Subject: [ASAN] bootconfig: Drop a pointless strdup in parser
|
||||
|
||||
Not entirely sure how this was leaking, but anyways it showed
|
||||
up in ASAN, and it's pointless to strdup here.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/libostree/ostree-bootconfig-parser.c | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/libostree/ostree-bootconfig-parser.c b/src/libostree/ostree-bootconfig-parser.c
|
||||
index f7728e4..a2ac107 100644
|
||||
--- a/src/libostree/ostree-bootconfig-parser.c
|
||||
+++ b/src/libostree/ostree-bootconfig-parser.c
|
||||
@@ -28,7 +28,7 @@ struct _OstreeBootconfigParser
|
||||
GObject parent_instance;
|
||||
|
||||
gboolean parsed;
|
||||
- char *separators;
|
||||
+ const char *separators;
|
||||
|
||||
GHashTable *options;
|
||||
GPtrArray *lines;
|
||||
@@ -235,7 +235,6 @@ ostree_bootconfig_parser_finalize (GObject *object)
|
||||
|
||||
g_hash_table_unref (self->options);
|
||||
g_ptr_array_unref (self->lines);
|
||||
- g_free (self->separators);
|
||||
|
||||
G_OBJECT_CLASS (ostree_bootconfig_parser_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -261,6 +260,6 @@ ostree_bootconfig_parser_new (void)
|
||||
OstreeBootconfigParser *self = NULL;
|
||||
|
||||
self = g_object_new (OSTREE_TYPE_BOOTCONFIG_PARSER, NULL);
|
||||
- self->separators = g_strdup (" \t");
|
||||
+ self->separators = " \t";
|
||||
return self;
|
||||
}
|
||||
35
debian/patches/ASAN-cmdline-Fix-minor-leak-in-delta-cmdline-entrypoint.patch
vendored
Normal file
35
debian/patches/ASAN-cmdline-Fix-minor-leak-in-delta-cmdline-entrypoint.patch
vendored
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 21:12:53 -0500
|
||||
Subject: [ASAN] cmdline: Fix minor leak in delta cmdline entrypoint
|
||||
|
||||
Small, but it's important to stay clean.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/ostree/ot-builtin-static-delta.c | 12 +++++++-----
|
||||
1 file changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/ostree/ot-builtin-static-delta.c b/src/ostree/ot-builtin-static-delta.c
|
||||
index ca29911..e1c3bb4 100644
|
||||
--- a/src/ostree/ot-builtin-static-delta.c
|
||||
+++ b/src/ostree/ot-builtin-static-delta.c
|
||||
@@ -336,11 +336,13 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
|
||||
g_print ("Generating static delta:\n");
|
||||
g_print (" From: %s\n", from_resolved ? from_resolved : "empty");
|
||||
g_print (" To: %s\n", to_resolved);
|
||||
- if (!ostree_repo_static_delta_generate (repo, OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR,
|
||||
- from_resolved, to_resolved, NULL,
|
||||
- g_variant_builder_end (parambuilder),
|
||||
- cancellable, error))
|
||||
- goto out;
|
||||
+ { g_autoptr(GVariant) params = g_variant_ref_sink (g_variant_builder_end (parambuilder));
|
||||
+ if (!ostree_repo_static_delta_generate (repo, OSTREE_STATIC_DELTA_GENERATE_OPT_MAJOR,
|
||||
+ from_resolved, to_resolved, NULL,
|
||||
+ params,
|
||||
+ cancellable, error))
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 21:11:37 -0500
|
||||
Subject: [ASAN] delta compilation: More leak fixes
|
||||
|
||||
Now that I remembered to do `env G_SLICE=always-malloc`, lots more
|
||||
leaks become apparent. Nothing major.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
.../ostree-repo-static-delta-compilation.c | 27 +++++++++++-----------
|
||||
1 file changed, 14 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/libostree/ostree-repo-static-delta-compilation.c b/src/libostree/ostree-repo-static-delta-compilation.c
|
||||
index 22c45e6..1611d19 100644
|
||||
--- a/src/libostree/ostree-repo-static-delta-compilation.c
|
||||
+++ b/src/libostree/ostree-repo-static-delta-compilation.c
|
||||
@@ -132,7 +132,7 @@ xattr_chunk_hash (const void *vp)
|
||||
{
|
||||
const guint8* name;
|
||||
const guint8* value_data;
|
||||
- GVariant *value = NULL;
|
||||
+ g_autoptr(GVariant) value = NULL;
|
||||
gsize value_len;
|
||||
|
||||
g_variant_get_child (v, i, "(^&ay@ay)",
|
||||
@@ -911,9 +911,8 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
||||
|
||||
ostree_object_name_deserialize (serialized_key, &checksum, &objtype);
|
||||
|
||||
- g_variant_ref (serialized_key);
|
||||
if (OSTREE_OBJECT_TYPE_IS_META (objtype))
|
||||
- g_hash_table_add (new_reachable_metadata, serialized_key);
|
||||
+ g_hash_table_add (new_reachable_metadata, g_variant_ref (serialized_key));
|
||||
else
|
||||
{
|
||||
g_autoptr(GFileInfo) finfo = NULL;
|
||||
@@ -955,8 +954,9 @@ generate_delta_lowlatency (OstreeRepo *repo,
|
||||
}
|
||||
|
||||
/* We already ship the to commit in the superblock, don't ship it twice */
|
||||
- g_hash_table_remove (new_reachable_metadata,
|
||||
- ostree_object_name_serialize (to, OSTREE_OBJECT_TYPE_COMMIT));
|
||||
+ { g_autoptr(GVariant) commit = ostree_object_name_serialize (to, OSTREE_OBJECT_TYPE_COMMIT);
|
||||
+ g_hash_table_remove (new_reachable_metadata, commit);
|
||||
+ }
|
||||
|
||||
rollsum_optimized_content_objects = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free,
|
||||
@@ -1359,8 +1359,8 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
for (i = 0; i < builder.parts->len; i++)
|
||||
{
|
||||
OstreeStaticDeltaPartBuilder *part_builder = builder.parts->pdata[i];
|
||||
- GBytes *payload_b;
|
||||
- GBytes *operations_b;
|
||||
+ g_autoptr(GBytes) payload_b;
|
||||
+ g_autoptr(GBytes) operations_b;
|
||||
g_autofree guchar *part_checksum = NULL;
|
||||
g_autoptr(GBytes) objtype_checksum_array = NULL;
|
||||
g_autoptr(GBytes) checksum_bytes = NULL;
|
||||
@@ -1415,10 +1415,11 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
}
|
||||
|
||||
/* FIXME - avoid duplicating memory here */
|
||||
- delta_part = g_variant_new ("(y@ay)",
|
||||
- compression_type_char,
|
||||
- ot_gvariant_new_ay_bytes (g_memory_output_stream_steal_as_bytes (part_payload_out)));
|
||||
- g_variant_ref_sink (delta_part);
|
||||
+ { g_autoptr(GBytes) payload = g_memory_output_stream_steal_as_bytes (part_payload_out);
|
||||
+ delta_part = g_variant_ref_sink (g_variant_new ("(y@ay)",
|
||||
+ compression_type_char,
|
||||
+ ot_gvariant_new_ay_bytes (payload)));
|
||||
+ }
|
||||
|
||||
if (inline_parts)
|
||||
{
|
||||
@@ -1532,7 +1533,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
/* floating */ GVariant *to_csum_v =
|
||||
ostree_checksum_to_bytes_v (to);
|
||||
|
||||
- delta_descriptor = g_variant_ref_sink (g_variant_new ("(@a{sv}t@ay@ay@" OSTREE_COMMIT_GVARIANT_STRING "ay"
|
||||
+ delta_descriptor = g_variant_ref_sink (g_variant_new ("(@a{sv}t@ay@ay@" OSTREE_COMMIT_GVARIANT_STRING "@ay"
|
||||
"a" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT
|
||||
"@a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT ")",
|
||||
g_variant_builder_end (&metadata_builder),
|
||||
@@ -1540,7 +1541,7 @@ ostree_repo_static_delta_generate (OstreeRepo *self,
|
||||
from_csum_v,
|
||||
to_csum_v,
|
||||
to_commit,
|
||||
- g_variant_builder_new (G_VARIANT_TYPE ("ay")),
|
||||
+ ot_gvariant_new_bytearray ((guchar*)"", 0),
|
||||
part_headers,
|
||||
fallback_headers));
|
||||
g_date_time_unref (now);
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 21:12:23 -0500
|
||||
Subject: [ASAN] deltas: Fix minor memory leak
|
||||
|
||||
We were leaking the checksum, ensure we free it in both normal and
|
||||
error paths.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/libostree/ostree-repo-static-delta-processing.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/libostree/ostree-repo-static-delta-processing.c b/src/libostree/ostree-repo-static-delta-processing.c
|
||||
index eabe392..ff5a8a1 100644
|
||||
--- a/src/libostree/ostree-repo-static-delta-processing.c
|
||||
+++ b/src/libostree/ostree-repo-static-delta-processing.c
|
||||
@@ -286,6 +286,7 @@ _ostree_static_delta_part_execute (OstreeRepo *repo,
|
||||
|
||||
ret = TRUE;
|
||||
out:
|
||||
+ g_clear_pointer (&state->content_checksum, g_checksum_free);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -941,6 +942,7 @@ dispatch_close (OstreeRepo *repo,
|
||||
goto out;
|
||||
|
||||
g_clear_pointer (&state->xattrs, g_variant_unref);
|
||||
+ g_clear_pointer (&state->content_checksum, g_checksum_free);
|
||||
g_clear_object (&state->content_out);
|
||||
|
||||
state->checksum_index++;
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 22:01:33 -0500
|
||||
Subject: [ASAN] metalink: Fix leaks of buffer
|
||||
|
||||
We should be religious about the "only set output variables on
|
||||
success", otherwise it makes leaks more likely.
|
||||
|
||||
But the real leak was us simply not using autoptr in one place.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/libostree/ostree-metalink.c | 13 ++++++++-----
|
||||
1 file changed, 8 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/libostree/ostree-metalink.c b/src/libostree/ostree-metalink.c
|
||||
index ad3d5bf..b3c8b15 100644
|
||||
--- a/src/libostree/ostree-metalink.c
|
||||
+++ b/src/libostree/ostree-metalink.c
|
||||
@@ -479,7 +479,7 @@ try_one_url (OstreeMetalinkRequest *self,
|
||||
|
||||
ret = TRUE;
|
||||
if (out_data)
|
||||
- *out_data = g_bytes_ref (bytes);
|
||||
+ *out_data = g_steal_pointer (&bytes);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
@@ -492,6 +492,7 @@ try_metalink_targets (OstreeMetalinkRequest *self,
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
SoupURI *target_uri = NULL;
|
||||
+ g_autoptr(GBytes) ret_data = NULL;
|
||||
|
||||
if (!self->found_a_file_element)
|
||||
{
|
||||
@@ -546,7 +547,7 @@ try_metalink_targets (OstreeMetalinkRequest *self,
|
||||
|
||||
target_uri = self->urls->pdata[self->current_url_index];
|
||||
|
||||
- if (try_one_url (self, target_uri, out_data, &temp_error))
|
||||
+ if (try_one_url (self, target_uri, &ret_data, &temp_error))
|
||||
break;
|
||||
else
|
||||
{
|
||||
@@ -568,6 +569,8 @@ try_metalink_targets (OstreeMetalinkRequest *self,
|
||||
ret = TRUE;
|
||||
if (out_target_uri)
|
||||
*out_target_uri = soup_uri_copy (target_uri);
|
||||
+ if (out_data)
|
||||
+ *out_data = g_steal_pointer (&ret_data);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
@@ -599,7 +602,7 @@ _ostree_metalink_request_sync (OstreeMetalink *self,
|
||||
gboolean ret = FALSE;
|
||||
OstreeMetalinkRequest request = { 0, };
|
||||
g_autoptr(GMainContext) mainctx = NULL;
|
||||
- GBytes *out_contents = NULL;
|
||||
+ g_autoptr(GBytes) contents = NULL;
|
||||
gsize len;
|
||||
const guint8 *data;
|
||||
|
||||
@@ -614,13 +617,13 @@ _ostree_metalink_request_sync (OstreeMetalink *self,
|
||||
self->uri,
|
||||
FALSE,
|
||||
FALSE,
|
||||
- &out_contents,
|
||||
+ &contents,
|
||||
self->max_size,
|
||||
cancellable,
|
||||
error))
|
||||
goto out;
|
||||
|
||||
- data = g_bytes_get_data (out_contents, &len);
|
||||
+ data = g_bytes_get_data (contents, &len);
|
||||
if (!g_markup_parse_context_parse (request.parser, (const char*)data, len, error))
|
||||
goto out;
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 22:03:24 -0500
|
||||
Subject: [ASAN] set-origin: Squash a leak
|
||||
|
||||
Just a minor leak in the commandline.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/ostree/ot-admin-builtin-set-origin.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/ostree/ot-admin-builtin-set-origin.c b/src/ostree/ot-admin-builtin-set-origin.c
|
||||
index 0e79ab5..2b6866c 100644
|
||||
--- a/src/ostree/ot-admin-builtin-set-origin.c
|
||||
+++ b/src/ostree/ot-admin-builtin-set-origin.c
|
||||
@@ -50,7 +50,7 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
|
||||
const char *branch = NULL;
|
||||
glnx_unref_object OstreeRepo *repo = NULL;
|
||||
glnx_unref_object OstreeSysroot *sysroot = NULL;
|
||||
- OstreeDeployment *target_deployment = NULL;
|
||||
+ glnx_unref_object OstreeDeployment *target_deployment = NULL;
|
||||
|
||||
context = g_option_context_new ("REMOTENAME URL [BRANCH]");
|
||||
|
||||
@@ -85,6 +85,8 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
|
||||
"Not currently booted into an OSTree system");
|
||||
goto out;
|
||||
}
|
||||
+ /* To match the below */
|
||||
+ target_deployment = g_object_ref (target_deployment);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 22:00:01 -0500
|
||||
Subject: [ASAN] sysroot: Fix leak/double free of keyfile origin
|
||||
|
||||
Use autoptr rather than manual cleanup. The double free isn't a
|
||||
security problem, since we trust origin files.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/libostree/ostree-deployment.c | 2 +-
|
||||
src/libostree/ostree-sysroot.c | 6 +-----
|
||||
2 files changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/libostree/ostree-deployment.c b/src/libostree/ostree-deployment.c
|
||||
index 7b93e6c..67e896b 100644
|
||||
--- a/src/libostree/ostree-deployment.c
|
||||
+++ b/src/libostree/ostree-deployment.c
|
||||
@@ -133,7 +133,6 @@ OstreeDeployment *
|
||||
ostree_deployment_clone (OstreeDeployment *self)
|
||||
{
|
||||
glnx_unref_object OstreeBootconfigParser *new_bootconfig = NULL;
|
||||
- GKeyFile *new_origin = NULL;
|
||||
OstreeDeployment *ret = ostree_deployment_new (self->index, self->osname, self->csum,
|
||||
self->deployserial,
|
||||
self->bootcsum, self->bootserial);
|
||||
@@ -143,6 +142,7 @@ ostree_deployment_clone (OstreeDeployment *self)
|
||||
|
||||
if (self->origin)
|
||||
{
|
||||
+ g_autoptr(GKeyFile) new_origin = NULL;
|
||||
g_autofree char *data = NULL;
|
||||
gsize len;
|
||||
gboolean success;
|
||||
diff --git a/src/libostree/ostree-sysroot.c b/src/libostree/ostree-sysroot.c
|
||||
index 608d4cf..70ce156 100644
|
||||
--- a/src/libostree/ostree-sysroot.c
|
||||
+++ b/src/libostree/ostree-sysroot.c
|
||||
@@ -613,8 +613,6 @@ parse_origin (OstreeSysroot *self,
|
||||
out:
|
||||
if (error)
|
||||
g_prefix_error (error, "Parsing %s: ", origin_path);
|
||||
- if (ret_origin)
|
||||
- g_key_file_unref (ret_origin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -689,7 +687,7 @@ parse_deployment (OstreeSysroot *self,
|
||||
glnx_fd_close int deployment_dfd = -1;
|
||||
const char *deploy_basename;
|
||||
g_autofree char *treebootserial_target = NULL;
|
||||
- GKeyFile *origin = NULL;
|
||||
+ g_autoptr(GKeyFile) origin = NULL;
|
||||
g_autofree char *unlocked_development_path = NULL;
|
||||
struct stat stbuf;
|
||||
|
||||
@@ -751,8 +749,6 @@ parse_deployment (OstreeSysroot *self,
|
||||
if (out_deployment)
|
||||
*out_deployment = g_steal_pointer (&ret_deployment);
|
||||
out:
|
||||
- if (origin)
|
||||
- g_key_file_unref (origin);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 22:03:53 -0500
|
||||
Subject: [ASAN] tests: Fix leaks
|
||||
|
||||
Just for cleaner sanitizer output.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
tests/test-basic-c.c | 1 -
|
||||
tests/test-keyfile-utils.c | 17 ++++++++++++++---
|
||||
tests/test-libarchive-import.c | 5 +++--
|
||||
tests/test-pull-c.c | 1 +
|
||||
tests/test-rollsum.c | 4 ++--
|
||||
5 files changed, 20 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/tests/test-basic-c.c b/tests/test-basic-c.c
|
||||
index 447c46e..8e7882b 100644
|
||||
--- a/tests/test-basic-c.c
|
||||
+++ b/tests/test-basic-c.c
|
||||
@@ -73,7 +73,6 @@ test_raw_file_to_archive_z2_stream (gconstpointer data)
|
||||
&commit_checksum,
|
||||
&error);
|
||||
g_assert_no_error (error);
|
||||
- reachable = ostree_repo_traverse_new_reachable ();
|
||||
ostree_repo_traverse_commit (repo,
|
||||
commit_checksum,
|
||||
-1,
|
||||
diff --git a/tests/test-keyfile-utils.c b/tests/test-keyfile-utils.c
|
||||
index 4bf3757..8fd5916 100644
|
||||
--- a/tests/test-keyfile-utils.c
|
||||
+++ b/tests/test-keyfile-utils.c
|
||||
@@ -31,7 +31,7 @@ static GKeyFile *g_keyfile;
|
||||
static void
|
||||
test_get_boolean_with_default (void)
|
||||
{
|
||||
- GError *error = NULL;
|
||||
+ g_autoptr(GError) error = NULL;
|
||||
gboolean out = FALSE;
|
||||
|
||||
GLogLevelFlags always_fatal_mask;
|
||||
@@ -46,18 +46,21 @@ test_get_boolean_with_default (void)
|
||||
FALSE,
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_error (&error);
|
||||
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
||||
NULL,
|
||||
"a_boolean_true",
|
||||
FALSE,
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_error (&error);
|
||||
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
||||
"section",
|
||||
NULL,
|
||||
FALSE,
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_error (&error);
|
||||
|
||||
/* Restore the old mask. */
|
||||
g_log_set_always_fatal (always_fatal_mask);
|
||||
@@ -86,6 +89,7 @@ test_get_boolean_with_default (void)
|
||||
&error));
|
||||
g_assert_true (out);
|
||||
|
||||
+ g_clear_error (&error);
|
||||
g_assert_false (ot_keyfile_get_boolean_with_default (g_keyfile,
|
||||
"a_fake_section",
|
||||
"a_boolean_true",
|
||||
@@ -97,8 +101,8 @@ test_get_boolean_with_default (void)
|
||||
static void
|
||||
test_get_value_with_default (void)
|
||||
{
|
||||
- GError *error = NULL;
|
||||
- char *out = NULL;
|
||||
+ g_autoptr(GError) error = NULL;
|
||||
+ g_autofree char *out = NULL;
|
||||
GLogLevelFlags always_fatal_mask;
|
||||
const char *section = "section";
|
||||
|
||||
@@ -112,18 +116,21 @@ test_get_value_with_default (void)
|
||||
"none",
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_pointer (&out, g_free);
|
||||
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
||||
section,
|
||||
NULL,
|
||||
"none",
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_pointer (&out, g_free);
|
||||
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
||||
section,
|
||||
NULL,
|
||||
"something",
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_pointer (&out, g_free);
|
||||
|
||||
/* Restore the old mask. */
|
||||
g_log_set_always_fatal (always_fatal_mask);
|
||||
@@ -135,6 +142,7 @@ test_get_value_with_default (void)
|
||||
&out,
|
||||
&error));
|
||||
g_assert_cmpstr (out, ==, "foo");
|
||||
+ g_clear_pointer (&out, g_free);
|
||||
|
||||
g_assert (ot_keyfile_get_value_with_default (g_keyfile,
|
||||
section,
|
||||
@@ -143,6 +151,7 @@ test_get_value_with_default (void)
|
||||
&out,
|
||||
&error));
|
||||
g_assert_cmpstr (out, ==, "correct");
|
||||
+ g_clear_pointer (&out, g_free);
|
||||
|
||||
g_assert_false (ot_keyfile_get_value_with_default (g_keyfile,
|
||||
"a_fake_section",
|
||||
@@ -150,6 +159,8 @@ test_get_value_with_default (void)
|
||||
"no value",
|
||||
&out,
|
||||
&error));
|
||||
+ g_clear_error (&error);
|
||||
+ g_clear_pointer (&out, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
diff --git a/tests/test-libarchive-import.c b/tests/test-libarchive-import.c
|
||||
index 05c5568..254d414 100644
|
||||
--- a/tests/test-libarchive-import.c
|
||||
+++ b/tests/test-libarchive-import.c
|
||||
@@ -180,7 +180,7 @@ static void
|
||||
test_libarchive_autocreate_empty (gconstpointer data)
|
||||
{
|
||||
TestData *td = (void*)data;
|
||||
- GError *error = NULL;
|
||||
+ g_autoptr(GError) error = NULL;
|
||||
struct archive *a = archive_read_new ();
|
||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||
@@ -198,7 +198,7 @@ static void
|
||||
test_libarchive_error_device_file (gconstpointer data)
|
||||
{
|
||||
TestData *td = (void*)data;
|
||||
- GError *error = NULL;
|
||||
+ g_autoptr(GError) error = NULL;
|
||||
struct archive *a = archive_read_new ();
|
||||
OstreeRepoImportArchiveOptions opts = { 0, };
|
||||
glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
|
||||
@@ -563,6 +563,7 @@ int main (int argc, char **argv)
|
||||
|
||||
r = g_test_run();
|
||||
|
||||
+ g_clear_object (&td.repo);
|
||||
if (td.tmpd && g_getenv ("TEST_SKIP_CLEANUP") == NULL)
|
||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, td.tmpd, NULL, NULL);
|
||||
g_free (td.tmpd);
|
||||
diff --git a/tests/test-pull-c.c b/tests/test-pull-c.c
|
||||
index d784312..43d5d61 100644
|
||||
--- a/tests/test-pull-c.c
|
||||
+++ b/tests/test-pull-c.c
|
||||
@@ -127,6 +127,7 @@ int main (int argc, char **argv)
|
||||
g_test_add_data_func ("/test-pull-c/multi-ok-error-repeat", &td, test_pull_multi_error_then_ok);
|
||||
|
||||
r = g_test_run();
|
||||
+ g_clear_object (&td.repo);
|
||||
|
||||
return r;
|
||||
}
|
||||
diff --git a/tests/test-rollsum.c b/tests/test-rollsum.c
|
||||
index 97aeb0a..1ed9964 100644
|
||||
--- a/tests/test-rollsum.c
|
||||
+++ b/tests/test-rollsum.c
|
||||
@@ -74,8 +74,8 @@ test_rollsum (void)
|
||||
#define MAX_BUFFER_SIZE 1000000
|
||||
gsize i;
|
||||
int len;
|
||||
- unsigned char *a = malloc (MAX_BUFFER_SIZE);
|
||||
- unsigned char *b = malloc (MAX_BUFFER_SIZE);
|
||||
+ g_autofree unsigned char *a = malloc (MAX_BUFFER_SIZE);
|
||||
+ g_autofree unsigned char *b = malloc (MAX_BUFFER_SIZE);
|
||||
g_autoptr(GRand) rand = g_rand_new ();
|
||||
|
||||
/* These two buffers produce the same crc32. */
|
||||
|
|
@ -4,4 +4,13 @@ ostree-repo-traverse-Don-t-leak-floating-GVariant.patch
|
|||
pull_with_options-Don-t-leak-csum_v.patch
|
||||
pull-Don-t-leak-delta-superblock-variants.patch
|
||||
delta-compilation-Fix-leak.patch
|
||||
ASAN-delta-compilation-More-leak-fixes.patch
|
||||
ASAN-deltas-Fix-minor-memory-leak.patch
|
||||
ASAN-cmdline-Fix-minor-leak-in-delta-cmdline-entrypoint.patch
|
||||
traverse-Use-g_hash_table_add.patch
|
||||
ASAN-sysroot-Fix-leak-double-free-of-keyfile-origin.patch
|
||||
ASAN-metalink-Fix-leaks-of-buffer.patch
|
||||
ASAN-bootconfig-Drop-a-pointless-strdup-in-parser.patch
|
||||
ASAN-set-origin-Squash-a-leak.patch
|
||||
ASAN-tests-Fix-leaks.patch
|
||||
Terminate-individual-tests-after-10-minutes.patch
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
From: Colin Walters <walters@verbum.org>
|
||||
Date: Mon, 28 Nov 2016 21:14:47 -0500
|
||||
Subject: traverse: Use g_hash_table_add
|
||||
|
||||
And "move semantics" via `g_steal_pointer()`. Just a minor code
|
||||
cleanup I noticed when I was hunting for a leak, which ended up being
|
||||
elsewhere.
|
||||
|
||||
Closes: #598
|
||||
Approved by: jlebon
|
||||
---
|
||||
src/libostree/ostree-repo-traverse.c | 9 +++------
|
||||
1 file changed, 3 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/libostree/ostree-repo-traverse.c b/src/libostree/ostree-repo-traverse.c
|
||||
index 46f8324..d125f01 100644
|
||||
--- a/src/libostree/ostree-repo-traverse.c
|
||||
+++ b/src/libostree/ostree-repo-traverse.c
|
||||
@@ -349,8 +349,7 @@ traverse_iter (OstreeRepo *repo,
|
||||
|
||||
g_debug ("Found file object %s", checksum);
|
||||
key = g_variant_ref_sink (ostree_object_name_serialize (checksum, OSTREE_OBJECT_TYPE_FILE));
|
||||
- g_hash_table_replace (inout_reachable, key, key);
|
||||
- key = NULL;
|
||||
+ g_hash_table_add (inout_reachable, g_steal_pointer (&key));
|
||||
}
|
||||
else if (iterres == OSTREE_REPO_COMMIT_ITER_RESULT_DIR)
|
||||
{
|
||||
@@ -364,14 +363,12 @@ traverse_iter (OstreeRepo *repo,
|
||||
g_debug ("Found dirtree object %s", content_checksum);
|
||||
g_debug ("Found dirmeta object %s", meta_checksum);
|
||||
key = g_variant_ref_sink (ostree_object_name_serialize (meta_checksum, OSTREE_OBJECT_TYPE_DIR_META));
|
||||
- g_hash_table_replace (inout_reachable, key, key);
|
||||
- key = NULL;
|
||||
+ g_hash_table_add (inout_reachable, g_steal_pointer (&key));
|
||||
|
||||
key = g_variant_ref_sink (ostree_object_name_serialize (content_checksum, OSTREE_OBJECT_TYPE_DIR_TREE));
|
||||
if (!g_hash_table_lookup (inout_reachable, key))
|
||||
{
|
||||
- g_hash_table_replace (inout_reachable, key, key);
|
||||
- key = NULL;
|
||||
+ g_hash_table_add (inout_reachable, g_steal_pointer (&key));
|
||||
|
||||
if (!traverse_dirtree (repo, content_checksum, inout_reachable,
|
||||
ignore_missing_dirs, cancellable, error))
|
||||
Loading…
Reference in New Issue