From f4c45f0429c354d154789c68ca3667c3f7042863 Mon Sep 17 00:00:00 2001 From: inoguchi Date: Wed, 7 Apr 2021 10:29:58 +0000 Subject: [PATCH] Avoid leak in error path ok and input from tb@ --- usr.bin/openssl/x509.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.bin/openssl/x509.c b/usr.bin/openssl/x509.c index 8651c317c06..4d497851ca7 100644 --- a/usr.bin/openssl/x509.c +++ b/usr.bin/openssl/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.21 2021/04/01 10:47:38 inoguchi Exp $ */ +/* $OpenBSD: x509.c,v 1.22 2021/04/07 10:29:58 inoguchi Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -977,11 +977,15 @@ x509_main(int argc, char **argv) bnser = ASN1_INTEGER_to_BN(ser, NULL); if (bnser == NULL) goto end; - if (!BN_add_word(bnser, 1)) + if (!BN_add_word(bnser, 1)) { + BN_free(bnser); goto end; + } ser = BN_to_ASN1_INTEGER(bnser, NULL); - if (ser == NULL) + if (ser == NULL) { + BN_free(bnser); goto end; + } BN_free(bnser); i2a_ASN1_INTEGER(out, ser); ASN1_INTEGER_free(ser); -- 2.20.1