Skip to content

Commit

Permalink
test: add xls with oom allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
sftse committed Oct 27, 2024
1 parent c28cc12 commit 1ffc325
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/cfb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,9 @@ impl Sectors {
r: &mut R,
len: usize,
) -> Result<Vec<u8>, CfbError> {
let mut chain = if len > 0 {
Vec::with_capacity(len)
} else {
Vec::new()
};
let mut chain = Vec::with_capacity(len);
while sector_id != ENDOFCHAIN {
// FIXME: see tests/OOM_alloc3.xls, this call OOMs
chain.extend_from_slice(self.get(sector_id, r)?);
sector_id = fats[sector_id as usize];
}
Expand Down
Binary file added tests/OOM_alloc3.xls
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2147,4 +2147,6 @@ fn test_high_byte_strings_and_unicode_strings_without_reserved_tags() {
fn test_oom_allocation() {
let _xls: Xls<_> = wb("OOM_alloc.xls");
let _xls: Xls<_> = wb("OOM_alloc2.xls");
// FIXME: kills all tests with abort unless unstable set_alloc_error_hook is used
// let _xls: Xls<_> = wb("OOM_alloc3.xls");
}

0 comments on commit 1ffc325

Please sign in to comment.