common: Fix several memory leaks

This commit is contained in:
Phaedrus Leeds
2021-05-02 20:49:03 -05:00
committed by Alexander Larsson
parent d191c2eb58
commit 756b9eae14
3 changed files with 11 additions and 9 deletions

View File

@@ -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);

View File

@@ -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%

View File

@@ -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)