fix CID 1596595: Resource leaks, and CID 1596594: (CHECKED_RETURN) master
authorPaul <paul@claws-mail.org>
Tue, 23 Apr 2024 08:20:18 +0000 (09:20 +0100)
committerPaul <paul@claws-mail.org>
Tue, 23 Apr 2024 08:20:18 +0000 (09:20 +0100)
src/compose.c

index cedd1cab0b23d2801a05ef294a729bcd08bef5e2..ca8530ffe1b0258395eb494ae8272c3c12f4d7dc 100644 (file)
@@ -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;
        }