]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
lib/pk.c: Free tmp_output on error to avoid memory leak
authorJiasheng Jiang <jian1000@purdue.edu>
Mon, 16 Jun 2025 05:21:09 +0000 (05:21 +0000)
committerDaiki Ueno <ueno@gnu.org>
Mon, 16 Jun 2025 05:21:09 +0000 (14:21 +0900)
Call gnutls_free() to release tmp_output if asn1_der_coding() fails, preventing memory leak.

Fixes: 6f9bfaac9 ("Use the PKCS #1 1.5 encoding provided by nettle (2.5) for encryption and signatures.")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
lib/pk.c

index ea788ac4b389b1122749239994631ab6d9f6dda4..65add2947e8a9bd47b9b5a25225b6ccf1ebdcdcc 100644 (file)
--- a/lib/pk.c
+++ b/lib/pk.c
@@ -658,6 +658,7 @@ int encode_ber_digest_info(const mac_entry_st *e, const gnutls_datum_t *digest,
        result = asn1_der_coding(dinfo, "", tmp_output, &tmp_output_size, NULL);
        if (result != ASN1_SUCCESS) {
                gnutls_assert();
+               gnutls_free(tmp_output);
                asn1_delete_structure(&dinfo);
                return _gnutls_asn2err(result);
        }