Skip to content

Commit 26c1651

Browse files
authored
fix for exception on unhandled heic box hdlr (#228)
1 parent f8c7a29 commit 26c1651

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

exifread/core/heic.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,13 @@ def _parse_iref(self, box: Box) -> None:
328328

329329
def find_exif(self) -> Tuple[int, bytes]:
330330
ftyp = self.expect_parse("ftyp")
331-
assert ftyp.major_brand == b"heic"
332-
assert ftyp.minor_version == 0
331+
if ftyp.major_brand != b"heic" or ftyp.minor_version != 0:
332+
return 0, b""
333+
333334
meta = self.expect_parse("meta")
334-
assert meta.subs["iinf"].exif_infe is not None
335+
if meta.subs["iinf"].exif_infe is None:
336+
return 0, b""
337+
335338
item_id = meta.subs["iinf"].exif_infe.item_id
336339
extents = meta.subs["iloc"].locs[item_id]
337340
logger.debug("HEIC: found Exif location.")

tests/resources/dump

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Opening: tests/resources/heic/heic_hdlr_box.jpg
2+
No EXIF information found
3+
14
Opening: tests/resources/heic/mobile/HMD_Nokia_8.3_5G.heif
25
EXIF ExposureProgram (Short): Unidentified
36
EXIF ExposureTime (Ratio): 1/5000
99.5 KB
Loading

0 commit comments

Comments
 (0)