From 6e9531430d70fe80b67782ed57f1526aec9ed711 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@sequoia-pgp.org>
Date: Thu, 28 Oct 2021 13:32:22 +0200
Subject: [PATCH] Fix hash context leak

The hash context is duplicated unconditionally, but there is an
execution path exiting the function without it being finalized.
---
 rpmio/rpmpgp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rpmio/rpmpgp.c b/rpmio/rpmpgp.c
index 861f670..1e4f667 100644
--- a/rpmio/rpmpgp.c
+++ b/rpmio/rpmpgp.c
@@ -1310,6 +1310,7 @@ rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx)
     }
 
     rpmDigestFinal(ctx, (void **)&hash, &hashlen, 0);
+    ctx = NULL;
 
     /* Compare leading 16 bits of digest for quick check. */
     if (hash == NULL || memcmp(hash, sig->signhash16, 2) != 0)
@@ -1333,6 +1334,7 @@ rpmRC pgpVerifySignature(pgpDigParams key, pgpDigParams sig, DIGEST_CTX hashctx)
 
 exit:
     free(hash);
+    rpmDigestFinal(ctx, NULL, NULL, 0);
     return res;
 
 }
-- 
1.8.3.1

