From f9b85d96a941ed761e2ee2a171d33f38f5c17f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Mon, 22 Jun 2015 18:39:57 +0200 Subject: [PATCH] Fix potential resource leak in X.509 parse dir Found with fbinfer. --- library/x509_crt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/x509_crt.c b/library/x509_crt.c index 0c3450a366..ed62e7bb7b 100644 --- a/library/x509_crt.c +++ b/library/x509_crt.c @@ -1155,7 +1155,10 @@ int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path ) #if defined(MBEDTLS_THREADING_PTHREAD) if( ( ret = mbedtls_mutex_lock( &mbedtls_threading_readdir_mutex ) ) != 0 ) + { + closedir( dir ); return( ret ); + } #endif while( ( entry = readdir( dir ) ) != NULL )