Backport 1.3: Resource leak fix on windows
Fix a resource leak on windows platform, in mbedtls_x509_crt_parse_path,
in case a failure. when an error occurs, goto cleanup, and free the
resource, instead of returning error code immediately.
diff --git a/library/x509_crt.c b/library/x509_crt.c
index b6ca74c..8fa63c5 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -1014,7 +1014,10 @@
p, (int) len - 1,
NULL, NULL );
if( w_ret == 0 )
- return( POLARSSL_ERR_X509_FILE_IO_ERROR );
+ {
+ ret = POLARSSL_ERR_X509_FILE_IO_ERROR;
+ goto cleanup;
+ }
w_ret = x509_crt_parse_file( chain, filename );
if( w_ret < 0 )
@@ -1027,6 +1030,7 @@
if( GetLastError() != ERROR_NO_MORE_FILES )
ret = POLARSSL_ERR_X509_FILE_IO_ERROR;
+cleanup:
FindClose( hFind );
#else /* _WIN32 */
int t_ret;