Browse Source

fix bug in read_file_binary(FILE *fp, std::vector<uint8_t> &fileBufferBytes) (#1821)

* fix function read_file_binary.

* fix read_file_binary function.
mat 4 years ago
parent
commit
957dcf32b3
1 changed files with 3 additions and 1 deletions
  1. 3 1
      include/igl/file_utils.cpp

+ 3 - 1
include/igl/file_utils.cpp

@@ -19,8 +19,10 @@ IGL_INLINE void read_file_binary(FILE *fp,
     fseek(fp, 0, SEEK_SET);
     fileBufferBytes.resize(sizeBytes);
 
-    if (fread((char *)fileBufferBytes.data(), 1, sizeBytes, fp) == sizeBytes)
+    if (fread((char*)fileBufferBytes.data(), 1, sizeBytes, fp) == sizeBytes) {
+      fclose(fp);
       return;
+    }
   }
 
   throw std::runtime_error("error reading from file");