From 41c90a20631c82c29070f4591411a6aa27f40b7b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 29 Dec 2025 09:23:56 +0100 Subject: [PATCH] Fix MIDI import edge-case when doubling allocation is insufficient MIDI file from #10079 - see also 65332e603b4 --- libs/evoral/libsmf/smf_save.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/evoral/libsmf/smf_save.c b/libs/evoral/libsmf/smf_save.c index 988ecc71d5..50b8f11916 100644 --- a/libs/evoral/libsmf/smf_save.c +++ b/libs/evoral/libsmf/smf_save.c @@ -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) {