Skip to content

Commit

Permalink
close if error in parsing header
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzamuto committed Feb 15, 2017
1 parent 025c258 commit b616959
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dcimg.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ def open(self, file_name=None):

with open(file_name, 'r') as f:
mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_COPY)
if mm[:5] != b"DCIMG":
mm.close()

self.mm = mm
self._parse_header()

try:
self._parse_header()
except RuntimeError:
self.close()

@property
def nfrms(self):
Expand Down

0 comments on commit b616959

Please sign in to comment.