summaryrefslogtreecommitdiffstats
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2017-01-11 18:08:10 +0100
committerSubv <subv2112@gmail.com>2017-01-11 22:38:04 +0100
commitf2f2572fed075d2dca5ae7abcea451ac5eb382ec (patch)
tree1a7f133a595f7362a79e3f06d1e0bcb8a4668706 /src/core/hle/svc.cpp
parentY2R: Use the proper error code when GetStandardCoefficient receives an invalid value. (diff)
downloadyuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.tar
yuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.tar.gz
yuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.tar.bz2
yuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.tar.lz
yuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.tar.xz
yuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.tar.zst
yuzu-f2f2572fed075d2dca5ae7abcea451ac5eb382ec.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/svc.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 2b242ff98..8cb6a1c94 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -598,10 +598,24 @@ static ResultCode GetThreadPriority(s32* priority, Kernel::Handle handle) {
/// Sets the priority for the specified thread
static ResultCode SetThreadPriority(Kernel::Handle handle, s32 priority) {
+ if (priority > THREADPRIO_LOWEST) {
+ return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS,
+ ErrorSummary::InvalidArgument, ErrorLevel::Usage);
+ }
+
SharedPtr<Kernel::Thread> thread = Kernel::g_handle_table.Get<Kernel::Thread>(handle);
if (thread == nullptr)
return ERR_INVALID_HANDLE;
+ using Kernel::ResourceLimit;
+ // Note: The kernel uses the current process's resource limit instead of
+ // the one from the thread owner's resource limit.
+ Kernel::SharedPtr<ResourceLimit>& resource_limit = Kernel::g_current_process->resource_limit;
+ if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) {
+ return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::OS,
+ ErrorSummary::WrongArgument, ErrorLevel::Permanent);
+ }
+
thread->SetPriority(priority);
thread->UpdatePriority();