SDL_mixer: music_ogg_stb.c: error-out early if the vorbis file has no samples (24bd7)

From 24bd73eb365f66886bbef2a49099aca5c2f62f0a Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 11 Dec 2023 05:51:02 +0300
Subject: [PATCH] music_ogg_stb.c: error-out early if the vorbis file has no
 samples

(cherry picked from commit 44c50c7c1dd14bd851ae95ec5315e65ee3c779af)
---
 src/codecs/music_ogg_stb.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/codecs/music_ogg_stb.c b/src/codecs/music_ogg_stb.c
index 80e79811..a41dad09 100644
--- a/src/codecs/music_ogg_stb.c
+++ b/src/codecs/music_ogg_stb.c
@@ -201,6 +201,14 @@ static void *OGG_CreateFromRW(SDL_RWops *src, SDL_bool freesrc)
     }
 
     rate = music->vi.sample_rate;
+
+    music->full_length = stb_vorbis_stream_length_in_samples(music->vf);
+    if (music->full_length <= 0) {
+        Mix_SetError("No samples in ogg/vorbis stream.");
+        OGG_Delete(music);
+        return NULL;
+    }
+
     vc = stb_vorbis_get_comment(music->vf);
     if (vc.comment_list != NULL) {
         for (i = 0; i < vc.comment_list_length; i++) {
@@ -253,7 +261,6 @@ static void *OGG_CreateFromRW(SDL_RWops *src, SDL_bool freesrc)
         }
     }
 
-    music->full_length = stb_vorbis_stream_length_in_samples(music->vf);
     if ((music->loop_end > 0) && (music->loop_end <= music->full_length) &&
         (music->loop_start < music->loop_end)) {
         music->loop = 1;