From 5cc3bb5e41a08cf82738facd62ef7fc9276318f7 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 27 Jun 2014 13:38:16 -0700 Subject: [PATCH] md5_file: fclose() if error --- lib/md5_file.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/md5_file.cpp b/lib/md5_file.cpp index a3f2b054ee..dfa5d0b2d4 100644 --- a/lib/md5_file.cpp +++ b/lib/md5_file.cpp @@ -70,9 +70,11 @@ int md5_file(const char* path, char* output, double& nbytes, bool is_gzip) { if (is_gzip) { n = (int)fread(buf, 1, 10, f); if (n != 10) { + fclose(f); return ERR_BAD_FORMAT; } if (buf[0] != 0x1f || buf[1] != 0x8b || buf[2] != 0x08) { + fclose(f); return ERR_BAD_FORMAT; } nbytes = 10;