Fix possible memory leak in <MD>_ext()
diff --git a/library/sha1.c b/library/sha1.c
index 64b70f0..42f3d6c 100644
--- a/library/sha1.c
+++ b/library/sha1.c
@@ -380,17 +380,18 @@
     mbedtls_sha1_init( &ctx );
 
     if( ( ret = mbedtls_sha1_starts_ext( &ctx ) ) != 0 )
-        return( ret );
+        goto exit;
 
     if( ( ret = mbedtls_sha1_update_ext( &ctx, input, ilen ) ) != 0 )
-        return( ret );
+        goto exit;
 
     if( ( ret = mbedtls_sha1_finish_ext( &ctx, output ) ) != 0 )
-        return( ret );
+        goto exit;
 
+exit:
     mbedtls_sha1_free( &ctx );
 
-    return( 0 );
+    return( ret );
 }
 
 #if defined(MBEDTLS_SELF_TEST)