Skip to content

Commit

Permalink
Fix several memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mwleeds authored and alexlarsson committed May 4, 2021
1 parent 4562627 commit 404d7c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/flatpak-builtins-document-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ flatpak_builtin_document_export (int argc, char **argv,
g_autofree char *dirname = NULL;
g_autofree char *doc_path = NULL;
XdpDbusDocuments *documents;
int fd, fd_id;
int i;
glnx_autofd int fd = -1;
int i, fd_id;
GUnixFDList *fd_list = NULL;
const char *doc_id;
struct stat stbuf;
Expand Down Expand Up @@ -173,7 +173,7 @@ flatpak_builtin_document_export (int argc, char **argv,

fd_list = g_unix_fd_list_new ();
fd_id = g_unix_fd_list_append (fd_list, fd, error);
close (fd);
glnx_close_fd (&fd);

if (opt_noexist)
{
Expand Down
7 changes: 4 additions & 3 deletions common/flatpak-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -13670,14 +13670,15 @@ parse_ref_file (GKeyFile *keyfile,
collection_id = g_key_file_get_string (keyfile, FLATPAK_REF_GROUP,
FLATPAK_REF_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, FLATPAK_REF_GROUP,
FLATPAK_REF_COLLECTION_ID_KEY, NULL);
}

if (collection_id != NULL && *collection_id == '\0')
collection_id = NULL;
g_clear_pointer (&collection_id, g_free);

if (collection_id != NULL && gpg_data == NULL)
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Collection ID requires GPG key to be provided"));
Expand Down
1 change: 1 addition & 0 deletions common/flatpak-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,7 @@ flatpak_parse_repofile (const char *remote_name,
decoded = g_base64_decode (gpg_key, &decoded_len);
if (decoded_len < 10) /* Check some minimal size so we don't get crap */
{
g_free (decoded);
flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Invalid gpg key"));
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion portal/flatpak-portal.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ handle_spawn (PortalFlatpak *object,
const gint *fds = NULL;
gint fds_len = 0;
g_autofree FdMapEntry *fd_map = NULL;
gchar **env;
g_auto(GStrv) env = NULL;
gint32 max_fd;
GKeyFile *app_info;
g_autoptr(GPtrArray) flatpak_argv = g_ptr_array_new_with_free_func (g_free);
Expand Down

0 comments on commit 404d7c6

Please sign in to comment.