From 460a862ee043672b5114c1a0b8d429c587764c89 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Tue, 1 Sep 2020 17:19:25 +0200 Subject: [PATCH] pkcs15-cert: Avoid memory leaks Thanks oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24056 --- src/libopensc/pkcs15-cert.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libopensc/pkcs15-cert.c b/src/libopensc/pkcs15-cert.c index 67733567..e8b71b6b 100644 --- a/src/libopensc/pkcs15-cert.c +++ b/src/libopensc/pkcs15-cert.c @@ -108,7 +108,6 @@ parse_x509_cert(sc_context_t *ctx, struct sc_pkcs15_der *der, struct sc_pkcs15_c if (!pubkey) LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Unable to decode subjectPublicKeyInfo from cert"); - sc_asn1_clear_algorithm_id(&sig_alg); if (serial && serial_len) { sc_format_asn1_entry(asn1_serial_number + 0, serial, &serial_len, 1); @@ -129,6 +128,8 @@ parse_x509_cert(sc_context_t *ctx, struct sc_pkcs15_der *der, struct sc_pkcs15_c } err: + /* not used for anything */ + sc_asn1_clear_algorithm_id(&sig_alg); free(serial); free(subject); free(issuer);