diff --git a/parser/src/dataset/read.rs b/parser/src/dataset/read.rs index 5805702a..22b72b41 100644 --- a/parser/src/dataset/read.rs +++ b/parser/src/dataset/read.rs @@ -377,7 +377,12 @@ where Err(DecoderError::DecodeItemHeader { source: dicom_encoding::decode::Error::ReadItemHeader { source, .. }, .. - }) if source.kind() == std::io::ErrorKind::UnexpectedEof => { + }) if source.kind() == std::io::ErrorKind::UnexpectedEof + && self.seq_delimiters.pop().map_or(false, |t| t.pixel_data) + => { + // Note: if `UnexpectedEof` was reached while inside a + // PixelData Sequence, then we assume that + // the end of a DICOM object was reached gracefully. self.hard_break = true; None }