File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 1- use std:: { fmt:: Debug , sync:: Arc } ;
1+ use std:: { collections :: HashSet , fmt:: Debug , sync:: Arc } ;
22
33use nom:: { number:: complete, sequence:: tuple} ;
44use thiserror:: Error ;
@@ -81,6 +81,7 @@ pub struct ExifIter {
8181
8282 // Iterating status
8383 ifds : Vec < IfdIter > ,
84+ visited_offsets : HashSet < usize > ,
8485}
8586
8687impl Debug for ExifIter {
@@ -115,6 +116,7 @@ impl ExifIter {
115116 tz,
116117 ifd0,
117118 ifds,
119+ visited_offsets : HashSet :: new ( ) ,
118120 }
119121 }
120122
@@ -131,6 +133,7 @@ impl ExifIter {
131133 tz : self . tz . clone ( ) ,
132134 ifd0,
133135 ifds,
136+ visited_offsets : HashSet :: new ( ) ,
134137 }
135138 }
136139
@@ -386,6 +389,15 @@ impl Iterator for ExifIter {
386389 // );
387390 // continue;
388391 // }
392+
393+ if new_ifd. offset > 0 {
394+ if self . visited_offsets . contains ( & new_ifd. offset ) {
395+ // Ignore repeated ifd parsing to avoid dead looping
396+ continue ;
397+ }
398+ self . visited_offsets . insert ( new_ifd. offset ) ;
399+ }
400+
389401 let is_subifd = if new_ifd. ifd_idx == ifd. ifd_idx {
390402 // Push the current ifd before enter sub-ifd.
391403 self . ifds . push ( ifd) ;
You can’t perform that action at this time.
0 commit comments