Skip to content

Commit fcdb4ef

Browse files
Assert 0xFF bytes when patching lzma headers
1 parent 9ddbfe1 commit fcdb4ef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/bundle.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,21 +512,24 @@ impl AssetBundle {
512512
});
513513
}
514514

515-
// The LZMA_alone encoder does not write the correct
516-
// buffer sizes to the headers, so sub them in.
515+
// The LZMA_alone encoder does not write the correct buffer sizes
516+
// to the headers (it writes all 0xFFs), so sub them in.
517517
for i in 0..self.levels.len() {
518518
let level_start = if i == 0 {
519519
0
520520
} else {
521521
level_ends[i - 1].compressed_end
522522
};
523+
523524
let level_size_uncompressed = level_sizes_uncompressed[i];
524525
let level_size_uncompressed_start = (level_start
525526
+ 1 // properties byte
526527
+ 4) // dict size
527528
as usize;
528-
buf[level_size_uncompressed_start..level_size_uncompressed_start + 8]
529-
.copy_from_slice(&(level_size_uncompressed).to_le_bytes());
529+
530+
let slice = &mut buf[level_size_uncompressed_start..level_size_uncompressed_start + 8];
531+
assert!(slice == [0xFF; 8]);
532+
slice.copy_from_slice(&level_size_uncompressed.to_le_bytes());
530533
}
531534

532535
let header = AssetBundleHeader::new(level_ends);

0 commit comments

Comments
 (0)