SDL: asyncio: SDL_LoadFileAsync was not null-terminating the file data.

From 10072bb07d80ba229a3d66dda232ddd7d4f798fa Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 20 Mar 2025 15:43:45 -0400
Subject: [PATCH] asyncio: SDL_LoadFileAsync was not null-terminating the file
 data.

---
 src/io/SDL_asyncio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/io/SDL_asyncio.c b/src/io/SDL_asyncio.c
index aa5ba871e4e99..51adf6b00794b 100644
--- a/src/io/SDL_asyncio.c
+++ b/src/io/SDL_asyncio.c
@@ -309,12 +309,13 @@ bool SDL_LoadFileAsync(const char *file, SDL_AsyncIOQueue *queue, void *userdata
     if (asyncio) {
         asyncio->oneshot = true;
 
-        void *ptr = NULL;
+        Uint8 *ptr = NULL;
         const Sint64 flen = SDL_GetAsyncIOSize(asyncio);
         if (flen >= 0) {
             // !!! FIXME: check if flen > address space, since it'll truncate and we'll just end up with an incomplete buffer or a crash.
-            ptr = SDL_malloc((size_t) (flen + 1));  // over-allocate by one so we can add a null-terminator.
+            ptr = (Uint8 *) SDL_malloc((size_t) (flen + 1));  // over-allocate by one so we can add a null-terminator.
             if (ptr) {
+                ptr[flen] = '\0';
                 retval = SDL_ReadAsyncIO(asyncio, ptr, 0, (Uint64) flen, queue, userdata);
                 if (!retval) {
                     SDL_free(ptr);