From b0debf54e0c684112bb2064133a31c701fc82455 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 28 Nov 2017 16:14:29 +0100 Subject: [PATCH] fix memory leak in netpgp's pgp_sign_buf() --- libs/netpgp/src/signature.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/netpgp/src/signature.c b/libs/netpgp/src/signature.c index b4795055..99c524e4 100644 --- a/libs/netpgp/src/signature.c +++ b/libs/netpgp/src/signature.c @@ -1224,7 +1224,7 @@ pgp_sign_buf(pgp_io_t *io, pgp_sig_type_t sig_type; pgp_hash_alg_t hash_alg; pgp_output_t *output; - pgp_memory_t *mem; + pgp_memory_t *mem = NULL; uint8_t keyid[PGP_KEY_ID_SIZE]; pgp_hash_t *hash; unsigned ret; @@ -1232,7 +1232,7 @@ pgp_sign_buf(pgp_io_t *io, sig = NULL; sig_type = PGP_SIG_BINARY; output = NULL; - mem = pgp_memory_new(); + //mem = pgp_memory_new(); // EDIT BY MR: fix memory leak - pointer is overwritten by pgp_setup_memory_write() below hash = NULL; hash_alg = pgp_str_to_hash_alg(hashname); @@ -1259,7 +1259,7 @@ pgp_sign_buf(pgp_io_t *io, pgp_start_sig(sig, seckey, hash_alg, sig_type); /* setup writer */ - pgp_setup_memory_write(&output, &mem, insize); + pgp_setup_memory_write(&output, &mem, insize); /* calls pgp_output_new() and pgp_memory_new() */ if (cleartext) { /* Do the signing */