SDL_mixer: native_midi_common.c (ReadMIDIFile): fix possible NULL ptr dereference. (59caf)

From 59caf947bd0b024c1790a4b3c6320793b467c165 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 25 May 2024 23:11:20 +0300
Subject: [PATCH] native_midi_common.c (ReadMIDIFile): fix possible NULL ptr
 dereference.

if allocation of mididata->track ever fails we'd still be dereferencing
it under 'bail'

(cherry picked from commit 9c5ccc06a8701eb593628e4772fa8c32909e301f)
---
 src/codecs/native_midi/native_midi_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/codecs/native_midi/native_midi_common.c b/src/codecs/native_midi/native_midi_common.c
index c7996d92..1fa7f32e 100644
--- a/src/codecs/native_midi/native_midi_common.c
+++ b/src/codecs/native_midi/native_midi_common.c
@@ -262,7 +262,7 @@ static MIDIEvent *MIDItoStream(MIDIFile *mididata)
 
 static int ReadMIDIFile(MIDIFile *mididata, SDL_RWops *src)
 {
-    int i = 0;
+    int i = -1;
     Uint32 ID;
     Uint32 size;
     Uint16 format;