From f21af338829500db9302294586f201c588d52e2c Mon Sep 17 00:00:00 2001 From: J-Donald Tournier Date: Mon, 7 Aug 2023 12:23:47 +0100 Subject: [PATCH] DICOM: fix multiframe encoding with explicit length sequences As discussed in #2690 --- core/file/dicom/element.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/file/dicom/element.cpp b/core/file/dicom/element.cpp index 34ad441f07..f42c77c375 100644 --- a/core/file/dicom/element.cpp +++ b/core/file/dicom/element.cpp @@ -228,10 +228,15 @@ namespace MR { - if (parents.size()) - if ((parents.back().end && data > parents.back().end) || - (group == GROUP_SEQUENCE && element == ELEMENT_SEQUENCE_DELIMITATION_ITEM)) + if (parents.size()) { + if (group == GROUP_SEQUENCE && element == ELEMENT_SEQUENCE_DELIMITATION_ITEM) { parents.pop_back(); + } + else { // Undefined length encoding: + while (parents.size() && parents.back().end && data > parents.back().end) + parents.pop_back(); + } + } if (is_new_sequence()) { if (size == LENGTH_UNDEFINED)