From eb6262a6b746141bc67a6a8a90bfc728065db385 Mon Sep 17 00:00:00 2001 From: Stoiko Ivanov Date: Thu, 11 Feb 2021 19:19:47 +0100 Subject: [PATCH] fix #3259: always free certificate file after reading it This commit mirrors e3c4007bc94956962c03da8c6853415d2fdf057c in pve-cluster. The fix there got lost with a refactoring for reusing the code here in pve-common in c92b771669e68a8b49906b8a0a68b533750567b0 Tested by repeadetly reading https://$pve-node:8006/nodes on a virtual testcluster. Signed-off-by: Stoiko Ivanov --- src/PVE/Certificate.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/PVE/Certificate.pm b/src/PVE/Certificate.pm index 5bc9848..31a7722 100644 --- a/src/PVE/Certificate.pm +++ b/src/PVE/Certificate.pm @@ -199,10 +199,8 @@ my $read_certificate = sub { or $ssl_die->("unable to read '$cert_path' - $!\n"); my $cert = Net::SSLeay::PEM_read_bio_X509($bio); - if (!$cert) { - Net::SSLeay::BIO_free($bio); - die "unable to read certificate from '$cert_path'\n"; - } + Net::SSLeay::BIO_free($bio); + die "unable to read certificate from '$cert_path'\n" if !$cert; return $cert; }; -- 2.39.2