From 02ce3bc38502f9102207fc5f88a100a2cddb764a Mon Sep 17 00:00:00 2001 From: Lazy-Coder-03 Date: Mon, 21 Sep 2026 13:04:35 +0530 Subject: [PATCH] kern: only check thread ids pointer when count is nonzero --- libraries/libmesosphere/source/svc/kern_svc_debug.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/libmesosphere/source/svc/kern_svc_debug.cpp b/libraries/libmesosphere/source/svc/kern_svc_debug.cpp index 39db3775b..3eb0958c1 100644 --- a/libraries/libmesosphere/source/svc/kern_svc_debug.cpp +++ b/libraries/libmesosphere/source/svc/kern_svc_debug.cpp @@ -141,11 +141,10 @@ namespace ams::kern::svc { /* Verify that the number of thread ids is valid. */ R_UNLESS((0 <= num_thread_ids && num_thread_ids <= MaximumDebuggableThreadCount), svc::ResultOutOfRange()); - R_UNLESS(GetCurrentProcess().GetPageTable().IsSafeUserPointer(KProcessAddress(user_thread_ids.GetUnsafePointer()), num_thread_ids * sizeof(uint64_t)), svc::ResultInvalidPointer()); - /* Copy the threads from userspace. */ uint64_t thread_ids[MaximumDebuggableThreadCount]; if (num_thread_ids > 0) { + R_UNLESS(GetCurrentProcess().GetPageTable().IsSafeUserPointer(KProcessAddress(user_thread_ids.GetUnsafePointer()), num_thread_ids * sizeof(uint64_t)), svc::ResultInvalidPointer()); R_TRY(user_thread_ids.CopyArrayTo(thread_ids, num_thread_ids)); }