SchedulerPolicy_SetPolicyValue(ContextPriority, THREAD_PRIORITY_BELOW_NORMAL) would erroneously throw an exception because THREAD_PRIORITY_BELOW_NORMAL == -1 and -1 > 6 when compared as unsigned.
From: Joachim Priesner joachim.priesner@web.de
SchedulerPolicy_SetPolicyValue(ContextPriority, THREAD_PRIORITY_BELOW_NORMAL) would erroneously throw an exception because THREAD_PRIORITY_BELOW_NORMAL == -1 and -1 > 6 when compared as unsigned. --- dlls/msvcrt/concurrency.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/msvcrt/concurrency.c b/dlls/msvcrt/concurrency.c index 561b4d23289..3d019a86f8f 100644 --- a/dlls/msvcrt/concurrency.c +++ b/dlls/msvcrt/concurrency.c @@ -1246,7 +1246,7 @@ unsigned int __thiscall SchedulerPolicy_SetPolicyValue(SchedulerPolicy *this, break; case ContextPriority: if (((int)val < -7 /* THREAD_PRIORITY_REALTIME_LOWEST */ - || val > 6 /* THREAD_PRIORITY_REALTIME_HIGHEST */) + || (int)val > 6 /* THREAD_PRIORITY_REALTIME_HIGHEST */) && val != THREAD_PRIORITY_IDLE && val != THREAD_PRIORITY_TIME_CRITICAL && val != INHERIT_THREAD_PRIORITY) { invalid_scheduler_policy_value e;
I didn't write a regression test because there aren't any tests for `concurrency` and I couldn't easily figure out how to test this C++ interface from C. Is there a good way to do that?
This merge request was approved by Piotr Caban.