[PATCH 0/1] MR7804: msvcrt: concurrency: Fix signed/unsigned comparison
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. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7804
From: Joachim Priesner <joachim.priesner(a)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; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7804
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? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7804#note_100710
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7804
participants (3)
-
Joachim Priesner -
Joachim Priesner (@jpr) -
Piotr Caban (@piotr)