SDL_mixer: music.c: Added proper detection of RIFF MIDI files (89720)

From 897205ca83b610e724f69a21ac329a935223cbc9 Mon Sep 17 00:00:00 2001
From: Wohlstand <[EMAIL REDACTED]>
Date: Wed, 31 May 2023 15:20:27 +0300
Subject: [PATCH] music.c: Added proper detection of RIFF MIDI files

---
 src/music.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/music.c b/src/music.c
index 5830d906..31929f8a 100644
--- a/src/music.c
+++ b/src/music.c
@@ -591,6 +591,11 @@ Mix_MusicType detect_music_type(SDL_RWops *src)
         return MUS_MID;
     }
 
+    /* RIFF MIDI files have the magic four bytes "RIFF" and then "RMID" */
+    if ((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp(magic + 8, "RMID", 4) == 0)) {
+        return MUS_MID;
+    }
+
     if (SDL_memcmp(magic, "ID3", 3) == 0 ||
     /* see: https://bugzilla.libsdl.org/show_bug.cgi?id=5322 */
         (magic[0] == 0xFF && (magic[1] & 0xE6) == 0xE2)) {