diff options
author | Phaedrus Leeds <mwleeds@protonmail.com> | 2021-05-02 20:49:03 -0500 |
---|---|---|
committer | Alexander Larsson <alexander.larsson@gmail.com> | 2021-05-04 10:23:13 +0200 |
commit | 756b9eae14087d4331c774d9973cb5fee9f1502d (patch) | |
tree | 1c52d8e302d31fd98a5e6c8e1d403a89300e8b6b | |
parent | d191c2eb586354055443848a95f945ed39dabadf (diff) | |
download | flatpak-756b9eae14087d4331c774d9973cb5fee9f1502d.tar.gz |
common: Fix several memory leaks
-rw-r--r-- | common/flatpak-dir.c | 12 | ||||
-rw-r--r-- | common/flatpak-progress.c | 4 | ||||
-rw-r--r-- | common/flatpak-utils.c | 4 |
3 files changed, 11 insertions, 9 deletions
diff --git a/common/flatpak-dir.c b/common/flatpak-dir.c index 9fc8920c..3aabd846 100644 --- a/common/flatpak-dir.c +++ b/common/flatpak-dir.c @@ -11812,6 +11812,7 @@ flatpak_dir_remote_fetch_indexed_summary (FlatpakDir *self, if (summary == NULL) return FALSE; + g_free (sha256); sha256 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, summary); if (strcmp (sha256, checksum) != 0) return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Invalid checksum for indexed summary %s for remote '%s'"), checksum, name_or_uri); @@ -12466,12 +12467,11 @@ find_matching_ref (GHashTable *refs, g_string_append (err, ", "); const char *branch = flatpak_decomposed_get_branch (ref); - - g_string_append (err, - g_strdup_printf ("%s/%s/%s", - name, - opt_arch ? opt_arch : "", - branch)); + g_string_append_printf (err, + "%s/%s/%s", + name, + opt_arch ? opt_arch : "", + branch); } flatpak_fail (error, "%s", err->str); diff --git a/common/flatpak-progress.c b/common/flatpak-progress.c index 7a0ea020..1e8842ae 100644 --- a/common/flatpak-progress.c +++ b/common/flatpak-progress.c @@ -186,8 +186,6 @@ update_status_progress_and_estimating (FlatpakProgress *self) gboolean last_was_metadata = self->last_was_metadata; g_autofree gchar *formatted_bytes_total_transferred = NULL; - buf = g_string_new (""); - /* We get some extra calls before we've really started due to the initialization of the extra data, so ignore those */ if (self->requested == 0) @@ -195,6 +193,8 @@ update_status_progress_and_estimating (FlatpakProgress *self) return; } + buf = g_string_new (""); + /* The heuristic here goes as follows: * - While fetching metadata, grow up to 5% * - Download goes up to 97% diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index f577d6e0..90036c6d 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -2302,7 +2302,9 @@ flatpak_parse_repofile (const char *remote_name, collection_id = g_key_file_get_string (keyfile, source_group, FLATPAK_REPO_DEPLOY_COLLECTION_ID_KEY, NULL); - if (collection_id == NULL || *collection_id == '\0') + if (collection_id != NULL && *collection_id == '\0') + g_clear_pointer (&collection_id, g_free); + if (collection_id == NULL) collection_id = g_key_file_get_string (keyfile, source_group, FLATPAK_REPO_COLLECTION_ID_KEY, NULL); if (collection_id != NULL) |