From 59d1aa181639275f8bd221d8e105b29b5b1fadba Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 23 Apr 2024 09:20:18 +0100 Subject: [PATCH] fix CID 1596595: Resource leaks, and CID 1596594: (CHECKED_RETURN) --- src/compose.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compose.c b/src/compose.c index cedd1cab0..ca8530ffe 100644 --- a/src/compose.c +++ b/src/compose.c @@ -11004,13 +11004,16 @@ int attach_image(Compose *compose, GtkSelectionData *data, const gchar *subtype) if ((fp = claws_fopen(file, "wb")) == NULL) { FILE_OP_ERROR(file, "claws_fopen"); + g_free(file); return -1; } if (claws_fwrite(contents, 1, len, fp) != len) { FILE_OP_ERROR(file, "claws_fwrite"); claws_fclose(fp); - claws_unlink(file); + if (claws_unlink(file) < 0) + FILE_OP_ERROR(file, "unlink"); + g_free(file); return -1; } @@ -11018,7 +11021,9 @@ int attach_image(Compose *compose, GtkSelectionData *data, const gchar *subtype) if (r == EOF) { FILE_OP_ERROR(file, "claws_fclose"); - claws_unlink(file); + if (claws_unlink(file) < 0) + FILE_OP_ERROR(file, "unlink"); + g_free(file); return -1; } -- 2.25.1