if ((err = gpgme_new(&data->ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(textdata);
return 0;
}
gpgme_set_textmode(data->ctx, 1);
src_codeset) < 0) {
FILE_OP_ERROR(fname, "fprintf");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
/* Store any part before encrypted text */
if (fwrite(textdata, 1, pos - textdata, dstfp) < pos - textdata) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
}
dstfp) < strlen(_("\n--- Start of PGP/Inline encrypted data ---\n"))) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
chars = sgpgme_data_release_and_get_mem(plain, &len);
if (len > 0) {
if (fwrite(chars, 1, len, dstfp) < len) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
}
/* Store any part after encrypted text */
dstfp) < strlen(_("--- End of PGP/Inline encrypted data ---\n"))) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
if (pos != NULL) {
pos = strstr(pos, end_indicator);
if (fwrite(pos, 1, strlen(pos), dstfp) < strlen(pos)) {
FILE_OP_ERROR(fname, "fwrite");
privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
- g_free(fname);
- gpgme_data_release(plain);
- gpgme_release(ctx);
- return NULL;
+ goto FILE_ERROR;
}
}
}
gpgme_release(ctx);
return decinfo;
+
+FILE_ERROR:
+ fclose(dstfp);
+ g_free(fname);
+ gpgme_data_release(plain);
+ gpgme_release(ctx);
+ return NULL;
}
static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *from_addr)
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
i = 0;
if (err) {
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);
return FALSE;
}
debug_print("found %s at %d\n", fprs[i], i);
if (!msgcontent->node->children) {
debug_print("msgcontent->node->children NULL, bailing\n");
privacy_set_error(_("Malformed message"));
+ g_free(kset);
return FALSE;
}
msgcontent = (MimeInfo *) msgcontent->node->children->data;
if (fp == NULL) {
privacy_set_error(_("Couldn't create temporary file, %s"), strerror(errno));
perror("my_tmpfile");
+ g_free(kset);
return FALSE;
}
procmime_write_mimeinfo(msgcontent, fp);
if ((err = gpgme_new(&ctx)) != GPG_ERR_NO_ERROR) {
debug_print(("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
privacy_set_error(_("Couldn't initialize GPG context, %s"), gpgme_strerror(err));
+ g_free(kset);
return FALSE;
}
gpgme_set_armor(ctx, 1);
err = gpgme_op_encrypt(ctx, kset, GPGME_ENCRYPT_ALWAYS_TRUST, gpgtext, gpgenc);
enccontent = sgpgme_data_release_and_get_mem(gpgenc, &len);
+ g_free(kset);
if (enccontent == NULL || len <= 0) {
g_warning("sgpgme_data_release_and_get_mem failed");