Fix MIDI import edge-case when doubling allocation is insufficient

MIDI file from #10079 - see also 65332e603b
This commit is contained in:
Robin Gareus
2025-12-29 09:23:56 +01:00
parent 8b2ede4d1a
commit 41c90a2063

View File

@@ -65,7 +65,9 @@ smf_extend(smf_t *smf, const int length)
if (smf->file_buffer_capacity == 0) {
smf->file_buffer_capacity = length * 2;
} else {
smf->file_buffer_capacity *= 2;
do {
smf->file_buffer_capacity *= 2;
} while (smf->file_buffer_capacity < smf->file_buffer_length + length);
}
smf->file_buffer = realloc(smf->file_buffer, smf->file_buffer_capacity);
if (smf->file_buffer == NULL) {