Skip to content

Commit 94a3583

Browse files
Add uncompressed chunk padding (#29)
1 parent 2629bf5 commit 94a3583

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pyaff4/aff4_image.py

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ def read(self, _):
8686
self.bevy_length += compressedLen
8787
return compressed_chunk
8888
else:
89+
# On final chunks that aren't compressed, pad if they are less than chunk_size
90+
# so that at decompression we won't try to decompress an already decompressed chunk.
91+
if chunkLen < self.owner.chunk_size:
92+
padding = self.owner.chunk_size - chunkLen
93+
chunk += b"\x00" * padding
8994
self.bevy_index.append((self.bevy_length, self.owner.chunk_size))
9095
self.bevy_length += self.owner.chunk_size
9196
return chunk

0 commit comments

Comments
 (0)