Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] [PATCH] reduce scope of and close a file descriptor in wsutil/sh

From: Toralf Förster <toralf.foerster@xxxxxx>
Date: Mon, 9 Jun 2014 19:32:49 +0200
spotted by cppcheck

Signed-off-by: Toralf Förster <toralf.foerster@xxxxxx>
---
 wsutil/sha1.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/wsutil/sha1.c b/wsutil/sha1.c
index fcafd2b..081881a 100644
--- a/wsutil/sha1.c
+++ b/wsutil/sha1.c
@@ -362,7 +362,6 @@ static const char *val[] =
 
 int main( int argc, char *argv[] )
 {
-    FILE *f;
     int i, j;
     char output[41];
     sha1_context ctx;
@@ -414,6 +413,8 @@ int main( int argc, char *argv[] )
     }
     else
     {
+        FILE *f;
+	
         if( ! ( f = ws_fopen( argv[1], "rb" ) ) )
         {
             printf("fopen: %s", g_strerror(errno));
@@ -426,6 +427,8 @@ int main( int argc, char *argv[] )
         {
             sha1_update( &ctx, buf, i );
         }
+        
+        ws_close(f);
 
         sha1_finish( &ctx, sha1sum );
 
-- 
2.0.0