--- a/mcabber/mcabber/pgp.c Tue Oct 06 21:16:41 2015 +0200
+++ b/mcabber/mcabber/pgp.c Wed Oct 07 21:55:51 2015 +0200
@@ -420,6 +420,10 @@
gpgme_set_armor(ctx, 1);
keys = g_new0(gpgme_key_t, 1+nkeys);
+ if (!keys) {
+ gpgme_release(ctx);
+ return NULL;
+ }
for (i = 0; i < nkeys; i++) {
err = gpgme_get_key(ctx, keyids[i], &keys[i], 0);
--- a/mcabber/mcabber/xmpp.c Tue Oct 06 21:16:41 2015 +0200
+++ b/mcabber/mcabber/xmpp.c Wed Oct 07 21:55:51 2015 +0200
@@ -385,10 +385,8 @@
if (key) {
int nkeys = 1;
const char *keys[] = { key, 0 };
- if (carbons_enabled()) {
- keys[1] = gpg_get_private_key_id();
- nkeys++;
- }
+ if (carbons_enabled())
+ keys[nkeys++] = gpg_get_private_key_id();
enc = gpg_encrypt(text, keys, nkeys);
}
if (!enc && force) {
@@ -1141,8 +1139,10 @@
scr_LogPrint(LPRINT_DEBUG, "Received incoming carbon from <%s>", from);
} else if (!g_strcmp0(carbon_name, "sent")) {
+#ifdef HAVE_GPGME
+ char *decrypted_pgp = NULL;
+#endif
guint encrypted = 0;
- char *decrypted_pgp = NULL;
const char *to= lm_message_node_get_attribute(x, "to");
if (!to) {
scr_LogPrint(LPRINT_LOGNORM, "Malformed carbon copy!");
@@ -1174,7 +1174,9 @@
hk_message_out(bjid, NULL, timestamp, body, encrypted, TRUE, NULL);
scr_LogPrint(LPRINT_DEBUG, "Received outgoing carbon for <%s>", to);
+#ifdef HAVE_GPGME
g_free(decrypted_pgp);
+#endif
goto handle_messages_return;
}
} else { // Not a Carbon