mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
winmm_midi: unprepare the earlier buffers when one fails (#19766)
When midiOutPrepareHeader failed on buffer i, the unwind loop "while (--i <= 0)" ran on an unsigned i: a failure on buffer 2 left buffers 0 and 1 prepared, and a failure on buffer 1 unprepared buffer 0 and stopped only because i wrapped. Count down with i-- > 0. Tests: under wine, with a harness that includes winmm_midi.c and fakes the two header calls. Before: a failure on the last buffer gives prepared 2, unprepared 0. After: a failure on buffer 0, 1 or 2 unprepares exactly what was prepared. Cross-compiled with x86_64-w64-mingw32-gcc -Wall -Wsign-compare, no warnings. Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
da111da0ca
commit
5d6dbddf94
1 file changed
+1
-1
@@ -287,7 +287,7 @@ static bool winmm_midi_init_output_buffers(HMIDISTRM dev,
|
||||
{
|
||||
RARCH_ERR("[MIDI] midiOutPrepareHeader failed with error %d.\n", mmr);
|
||||
|
||||
while (--i <= 0)
|
||||
while (i-- > 0)
|
||||
midiOutUnprepareHeader((HMIDIOUT)dev, &bufs[i].header, sizeof(MIDIHDR));
|
||||
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user