From bcc030849a1615528287fa5a7276cf3335be51d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 24 Jun 2015 00:09:29 +0200 Subject: [PATCH] Avoid fclose( NULL ) Found by Coverity Scan. --- library/md.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/library/md.c b/library/md.c index 1d6191fc2..1220a8750 100644 --- a/library/md.c +++ b/library/md.c @@ -284,13 +284,10 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigne if( md_info == NULL ) return( MBEDTLS_ERR_MD_BAD_INPUT_DATA ); - mbedtls_md_init( &ctx ); - if( ( f = fopen( path, "rb" ) ) == NULL ) - { - ret = MBEDTLS_ERR_MD_FILE_IO_ERROR; - goto cleanup; - } + return( MBEDTLS_ERR_MD_FILE_IO_ERROR ); + + mbedtls_md_init( &ctx ); if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 ) goto cleanup;