Fix CID 1492200 and 1491225: resource leaks.

This commit is contained in:
wwp 2021-09-28 17:40:39 +02:00
parent 0c24121784
commit b0a8b76177

View file

@ -72,6 +72,7 @@ static PrivacyDataPGP *pgpinline_new_privacydata()
data->sigstatus = NULL;
if ((err = gpgme_new(&data->ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s\n"), gpgme_strerror(err));
g_free(data);
return NULL;
}
@ -657,6 +658,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
debug_print(("Couldn't initialize GPG context, %s\n"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
g_free(kset);
g_free(fprs);
return FALSE;
}
i = 0;
@ -667,6 +669,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
debug_print("can't add key '%s'[%d] (%s)\n", fprs[i],i, gpgme_strerror(err));
privacy_set_error(_("Couldn't add GPG key %s, %s"), fprs[i], gpgme_strerror(err));
g_free(kset);
g_free(fprs);
return FALSE;
}
debug_print("found %s at %d\n", fprs[i], i);
@ -674,7 +677,6 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
i++;
}
debug_print("Encrypting message content\n");
/* get content node from message */
@ -684,6 +686,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
debug_print("msgcontent->node->children NULL, bailing\n");
privacy_set_error(_("Malformed message"));
g_free(kset);
g_free(fprs);
return FALSE;
}
msgcontent = (MimeInfo *) msgcontent->node->children->data;
@ -696,6 +699,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
privacy_set_error(_("Couldn't create temporary file, %s"), g_strerror(errno));
perror("my_tmpfile");
g_free(kset);
g_free(fprs);
return FALSE;
}
procmime_write_mimeinfo(msgcontent, fp);
@ -713,6 +717,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
debug_print(("Couldn't initialize GPG context, %s\n"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
g_free(kset);
g_free(fprs);
return FALSE;
}
gpgme_set_armor(ctx, 1);
@ -729,6 +734,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
g_free(textstr);
gpgme_release(ctx);
g_free(enccontent);
g_free(fprs);
return FALSE;
}
@ -751,6 +757,8 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
g_free(tmp);
gpgme_release(ctx);
g_free(fprs);
return TRUE;
}