diff --git a/src/exif.rs b/src/exif.rs index 78f5b43..f3da1eb 100644 --- a/src/exif.rs +++ b/src/exif.rs @@ -236,6 +236,8 @@ pub async fn parse_exif_async( #[cfg(test)] #[allow(deprecated)] mod tests { + use std::{sync::mpsc, thread, time::Duration}; + use crate::{ file::MimeImage, testkit::{open_sample, read_sample}, @@ -349,4 +351,21 @@ mod tests { .collect(); assert_eq!(res.join(", "), "Make => Apple, Model => iPhone 12 Pro"); } + + #[test] + fn endless_loop() { + let (sender, receiver) = mpsc::channel(); + + thread::spawn(move || { + let name = "endless_loop.jpg"; + let f = open_sample(name).unwrap(); + let iter = parse_exif(f, None).unwrap().unwrap(); + let _: Exif = iter.into(); + sender.send(()).unwrap(); + }); + + receiver + .recv_timeout(Duration::from_secs(1)) + .expect("There is an infinite loop in the parsing process!"); + } } diff --git a/testdata/endless_loop.jpg b/testdata/endless_loop.jpg new file mode 100644 index 0000000..9653d93 Binary files /dev/null and b/testdata/endless_loop.jpg differ