From 6087f200bffe5f518f2df0883a7fe4b259f994d5 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 4 May 2018 08:34:22 +0200 Subject: [PATCH] Fix memory leak in mbedtls_x509_csr_parse --- library/x509_csr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/x509_csr.c b/library/x509_csr.c index 26a06db4f..8bb7f3363 100644 --- a/library/x509_csr.c +++ b/library/x509_csr.c @@ -294,11 +294,9 @@ int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, siz /* * Was PEM encoded, parse the result */ - if( ( ret = mbedtls_x509_csr_parse_der( csr, pem.buf, pem.buflen ) ) != 0 ) - return( ret ); - + ret = mbedtls_x509_csr_parse_der( csr, pem.buf, pem.buflen ); mbedtls_pem_free( &pem ); - return( 0 ); + return( ret ); } else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) {