From d2477c1a29662f78664eb7f345cb339a1064d404 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 30 Aug 2022 08:45:06 +0000 Subject: [PATCH] Plug memory leak in X509_REQ_print_ex() CID 356353 ok jsing --- lib/libcrypto/asn1/t_req.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/asn1/t_req.c b/lib/libcrypto/asn1/t_req.c index 4b27a4ddbe1..81f7dd29e87 100644 --- a/lib/libcrypto/asn1/t_req.c +++ b/lib/libcrypto/asn1/t_req.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t_req.c,v 1.22 2022/05/09 19:19:33 jsing Exp $ */ +/* $OpenBSD: t_req.c,v 1.23 2022/08/30 08:45:06 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -102,7 +102,7 @@ X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, X509_REQ_INFO *ri; EVP_PKEY *pkey; STACK_OF(X509_ATTRIBUTE) *sk; - STACK_OF(X509_EXTENSION) *exts; + STACK_OF(X509_EXTENSION) *exts = NULL; char mlch = ' '; int nmindent = 0; @@ -238,6 +238,7 @@ X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, goto err; } sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); + exts = NULL; } } @@ -249,6 +250,7 @@ X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, return (1); err: + sk_X509_EXTENSION_pop_free(exts, X509_EXTENSION_free); X509error(ERR_R_BUF_LIB); return (0); } -- 2.20.1