Message-ID: Date: Wed, 23 Nov 2022 18:17:03 +0100 MIME-Version: 1.0 References: <20221123154912.28394-1-maximilian.fillinger@...2507...> Content-Language: en-GB From: Arne Schwabe In-Reply-To: <20221123154912.28394-1-maximilian.fillinger@...2507...> Subject: Re: [Openvpn-devel] [PATCH] Check if pkcs11_cert is NULL before freeing it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit To: Max Fillinger , openvpn-devel@lists.sourceforge.net Am 23.11.22 um 16:49 schrieb Max Fillinger: > When running openvpn --show-tls with mbedtls, it showed a null pointer > error at the end because of this. > > Signed-off-by: Max Fillinger > --- > src/openvpn/ssl_mbedtls.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c > index ea06cf70..aa55a1a0 100644 > --- a/src/openvpn/ssl_mbedtls.c > +++ b/src/openvpn/ssl_mbedtls.c > @@ -165,7 +165,10 @@ tls_ctx_free(struct tls_root_ctx *ctx) > free(ctx->crl); > > #if defined(ENABLE_PKCS11) > - pkcs11h_certificate_freeCertificate(ctx->pkcs11_cert); > + if (ctx->pkcs11_cert) > + { > + pkcs11h_certificate_freeCertificate(ctx->pkcs11_cert); > + } > #endif > > free(ctx->allowed_ciphers); Sigh, a function that violates the C paradigm that calling somethingfree on a null pointer is fine. Maybe we should add as a comment that this function is special in this way. Acked-By: Arne Schwabe Arne