From 7021774b49e154734f25073d7972bb2539eda61c 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 2e742b37..1458bbcc 100644
--- a/src/music.c
+++ b/src/music.c
@@ -592,6 +592,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)) {