lib: handle case where there aren't enough bytes for padding before an alignment boundary

This commit is contained in:
itsmattkc 2022-07-18 15:28:05 -07:00
parent f37a72b0d1
commit 0443b9e69b

View file

@ -600,6 +600,19 @@ void Interleaf::WriteSubChunk(FileBase *f, uint16_t flags, uint32_t object, uint
if (start_buffer != stop_buffer) {
size_t remaining = ((start_buffer + 1) * m_BufferSize) - f->pos();
if (remaining < total_hdr) {
if (remaining < kMinimumChunkSize) {
// There isn't enough space for another chunk, just jump ahead
f->seek(remaining, File::SeekCurrent);
} else {
// This chunk won't fit in our buffer alignment. We must make a decision to either insert
// padding or split the clip.
WritePadding(f, remaining);
}
continue;
}
max_chunk = remaining - total_hdr;
if (!(flags & MxCh::FLAG_SPLIT)) {