From 8a309c30a9fa893ff968c0db2b958d9e11847607 Mon Sep 17 00:00:00 2001
From: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com>
Date: Sun, 12 Jan 2025 03:24:49 -0600
Subject: [PATCH] Check thread param on posix_pthread_rename_np (#2133)

---
 src/core/libraries/kernel/threads/pthread.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/core/libraries/kernel/threads/pthread.cpp b/src/core/libraries/kernel/threads/pthread.cpp
index e81207a0d..639ed1611 100644
--- a/src/core/libraries/kernel/threads/pthread.cpp
+++ b/src/core/libraries/kernel/threads/pthread.cpp
@@ -386,6 +386,9 @@ int PS4_SYSV_ABI posix_sched_get_priority_min() {
 }
 
 int PS4_SYSV_ABI posix_pthread_rename_np(PthreadT thread, const char* name) {
+    if (thread == nullptr) {
+        return POSIX_EINVAL;
+    }
     LOG_INFO(Kernel_Pthread, "name = {}", name);
     Common::SetThreadName(reinterpret_cast<void*>(thread->native_thr.GetHandle()), name);
     thread->name = name;