commit 59d1aa181639275f8bd221d8e105b29b5b1fadba
parent e7e6d98b71b44c060cd0ec5f62fb8db5dd67b83a
Author: Paul <paul@claws-mail.org>
Date: Tue, 23 Apr 2024 09:20:18 +0100
fix CID 1596595: Resource leaks, and CID 1596594: (CHECKED_RETURN)
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git 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;
}