Index: b/cipher/pubkey.c =================================================================== --- b/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -2876,8 +2876,11 @@ init_encoding_ctx (&ctx, PUBKEY_OP_ENCRYPT, gcry_pk_get_nbits (s_pkey)); rc = sexp_data_to_mpi (s_data, &data, &ctx); if (rc) + { + mpi_free (data); + data = NULL; goto leave; - + } /* Now we can encrypt DATA to CIPH. */ ciph = gcry_calloc (strlen (algo_elems) + 1, sizeof (*ciph)); if (!ciph) @@ -3620,6 +3623,7 @@ if (!arg_list) { rc = gpg_err_code_from_syserror (); + gcry_free (string) goto leave; } for (i = j = 0; i < elem_n; i++)