SDL_image: xcf: Permit empty strings in read_string(). (e5732)

From e57322740002aa4ea49b629e95efbf93363113b9 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 6 Apr 2026 14:53:45 -0400
Subject: [PATCH] xcf: Permit empty strings in read_string().

Reference Issue #716.

(manual backport of commit 1da905ae95748edbf063102574be5f25ff42ae39)
---
 IMG_xcf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/IMG_xcf.c b/IMG_xcf.c
index 8d93709b..5ed99741 100644
--- a/IMG_xcf.c
+++ b/IMG_xcf.c
@@ -243,7 +243,15 @@ static char * read_string (SDL_RWops * src) {
 
   tmp = SDL_ReadBE32 (src);
   remaining = SDL12_RWsize(src) - SDL_RWtell(src);
-  if (tmp > 0 && tmp <= remaining) {
+  if (tmp == 0) {
+    data = (char *) malloc(1);
+    if (data) {
+      data[0] = 0;
+    }
+    return data;
+  }
+
+  if ((Sint32)tmp <= remaining) {
     data = (char *) malloc (sizeof (char) * tmp);
     if (data) {
       SDL_RWread(src, data, tmp, 1);