Fix CID 1491069 and 1491256: resource leaks.
authorwwp <subscript@free.fr>
Tue, 28 Sep 2021 12:45:12 +0000 (14:45 +0200)
committerwwp <subscript@free.fr>
Tue, 28 Sep 2021 12:45:12 +0000 (14:45 +0200)
src/plugins/smime/smime.c

index b8905f3ae16e00997dae4ae78ea5c55da0dd0300..976039486eaae4572e4886558430573de0dd46de 100644 (file)
@@ -744,6 +744,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
 
        if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
                debug_print ("gpgme_new failed: %s\n", gpgme_strerror(err));
+               g_free(fprs);
                return FALSE;
        }
 
@@ -752,6 +753,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        if (err) {
                debug_print ("gpgme_set_protocol failed: %s\n",
                    gpgme_strerror (err));
+               g_free(fprs);
                return FALSE;
        }
 
@@ -771,7 +773,8 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
                kset[i] = key;
                i++;
        }
-       
+       g_free(fprs);
+
        debug_print("Encrypting message content\n");
 
        /* remove content node from message */
@@ -801,6 +804,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        if (fp == NULL) {
                FILE_OP_ERROR(tmpfile, "create");
                g_free(kset);
+               g_free(tmpfile);
                return FALSE;
        }
        procmime_decode_content(msgcontent);
@@ -812,6 +816,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        if (fp == NULL) {
                FILE_OP_ERROR(tmpfile, "open");
                g_free(kset);
+               g_free(tmpfile);
                return FALSE;
        }
        g_free(tmpfile);
@@ -846,7 +851,7 @@ gboolean smime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
                        claws_unlink(tmpfile);
                        g_free(tmpfile);
                        g_free(enccontent);
-                       return FALSE;
+                       g_free(tmpfile);
                }
                if (claws_safe_fclose(fp) == EOF) {
                        FILE_OP_ERROR(tmpfile, "claws_fclose");