SDL_mixer: SDL_mixer_metadata_tags.c:parse_id3v1_ansi_string(): Fixed "always true" expression

From 59a2f77645404aee3ab541c6c860970da7572bed Mon Sep 17 00:00:00 2001
From: Petar Popovic <[EMAIL REDACTED]>
Date: Sat, 26 Jul 2025 14:42:22 +0200
Subject: [PATCH] SDL_mixer_metadata_tags.c:parse_id3v1_ansi_string(): Fixed
 "always true" expression

---
 src/SDL_mixer_metadata_tags.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/SDL_mixer_metadata_tags.c b/src/SDL_mixer_metadata_tags.c
index 985d14c2..6fe00a77 100644
--- a/src/SDL_mixer_metadata_tags.c
+++ b/src/SDL_mixer_metadata_tags.c
@@ -96,9 +96,17 @@ static char *parse_id3v1_ansi_string(const Uint8 *buffer, size_t src_len)
     src_buffer[src_len] = '\0';
 
     // trim whitespace from end (some id3v1 tags pad out with space instead of nulls).
-    for (size_t i = src_len - 1; (i >= 0) && (src_buffer[i] == ' '); i--) {
-        src_buffer[i] = '\0';
-        src_len--;
+    if (src_len > 0) {
+        size_t i = src_len;
+        do {
+            --i;
+            if (src_buffer[i] == ' ') {
+                src_buffer[i] = '\0';
+                --src_len;
+            } else {
+                break;
+            }
+        } while(i > 0);
     }
 
     char *ret = SDL_iconv_string("UTF-8", "ISO-8859-1", src_buffer, src_len + 1);