Skip to content

Commit

Permalink
Fix an error in the Deserializer::read_to_end when feature "overlap…
Browse files Browse the repository at this point in the history
…ped-lists" is enabled
  • Loading branch information
Mingun committed Dec 25, 2022
1 parent a5a48a2 commit 2e1eb0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Expand Up @@ -17,6 +17,8 @@
- [#530]: Fix an infinity loop that leads to an infinity memory consumption during
skipping events when `overlapped-lists` feature is active and malformed XML is
parsed
- [#530]: Fix an error in the `Deserializer::read_to_end` when `overlapped-lists`
feature is active and malformed XML is parsed

### Misc Changes

Expand Down
14 changes: 12 additions & 2 deletions src/de/mod.rs
Expand Up @@ -2237,7 +2237,7 @@ where
}
Some(DeEvent::End(e)) if e.name() == name => {
if depth == 0 {
return Ok(());
break;
}
depth -= 1;
}
Expand All @@ -2247,9 +2247,19 @@ where

// If we do not have skipped events, use effective reading that will
// not allocate memory for events
None => return self.reader.read_to_end(name),
None => {
loop {
self.reader.read_to_end(name)?;
if depth == 0 {
break;
}
depth -= 1;
}
break;
}
}
}
Ok(())
}
#[cfg(not(feature = "overlapped-lists"))]
fn read_to_end(&mut self, name: QName) -> Result<(), DeError> {
Expand Down

0 comments on commit 2e1eb0d

Please sign in to comment.