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

From 2d2928376e1e044fd9e501d25e6e39e71b8fb85c Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 6 Apr 2026 14:53:45 -0400
Subject: [PATCH] xcf: Permit empty strings in read_string().

Reference Issue #716.

(cherry picked from commit 1da905ae95748edbf063102574be5f25ff42ae39)
---
 src/IMG_xcf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/IMG_xcf.c b/src/IMG_xcf.c
index a1683ece..ed7d203f 100644
--- a/src/IMG_xcf.c
+++ b/src/IMG_xcf.c
@@ -233,7 +233,15 @@ static char * read_string (SDL_RWops * src) {
 
   tmp = SDL_ReadBE32(src);
   remaining = SDL_RWsize(src) - SDL_RWtell(src);
-  if (tmp > 0 && (Sint32)tmp <= remaining) {
+  if (tmp == 0) {
+    data = (char *) SDL_malloc(1);
+    if (data) {
+      data[0] = 0;
+    }
+    return data;
+  }
+
+  if ((Sint32)tmp <= remaining) {
     data = (char *) SDL_malloc (sizeof (char) * tmp);
     if (data) {
       SDL_RWread(src, data, tmp, 1);