SDL: PSP: Truncate thread name when passing to sceKernelCreateThread (309d1)

From 309d1481a4973877926e9922c80903f7ddeb5fde Mon Sep 17 00:00:00 2001
From: Wouter Wijsman <[EMAIL REDACTED]>
Date: Mon, 7 Jul 2025 19:07:33 +0200
Subject: [PATCH] PSP: Truncate thread name when passing to
 sceKernelCreateThread

---
 src/thread/psp/SDL_systhread.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/thread/psp/SDL_systhread.c b/src/thread/psp/SDL_systhread.c
index d2aa03e001160..b38bb73e5cf1d 100644
--- a/src/thread/psp/SDL_systhread.c
+++ b/src/thread/psp/SDL_systhread.c
@@ -34,6 +34,8 @@
 #include <pspkerneltypes.h>
 #include <pspthreadman.h>
 
+#define PSP_THREAD_NAME_MAX 32
+
 static int ThreadEntry(SceSize args, void *argp)
 {
     SDL_RunThread(*(SDL_Thread **)argp);
@@ -44,6 +46,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
 {
     SceKernelThreadInfo status;
     int priority = 32;
+    char thread_name[PSP_THREAD_NAME_MAX];
 
     /* Set priority of new thread to the same as the current thread */
     status.size = sizeof(SceKernelThreadInfo);
@@ -51,7 +54,12 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
         priority = status.currentPriority;
     }
 
-    thread->handle = sceKernelCreateThread(thread->name, ThreadEntry,
+    SDL_strlcpy(thread_name, "SDL thread", PSP_THREAD_NAME_MAX);
+    if (thread->name) {
+        SDL_strlcpy(thread_name, thread->name, PSP_THREAD_NAME_MAX);
+    }
+
+    thread->handle = sceKernelCreateThread(thread_name, ThreadEntry,
                                            priority, thread->stacksize ? ((int)thread->stacksize) : 0x8000,
                                            PSP_THREAD_ATTR_VFPU, NULL);
     if (thread->handle < 0) {