Skip to content

Commit 4d818a2

Browse files
committed
Make the error checking more robust
1 parent 4a53a5f commit 4d818a2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Modules/posixmodule.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7523,8 +7523,10 @@ os_sched_get_priority_max_impl(PyObject *module, int policy)
75237523
{
75247524
int max;
75257525

7526+
/* make sure that errno is cleared before the call */
7527+
errno = 0;
75267528
max = sched_get_priority_max(policy);
7527-
if (max == -1)
7529+
if (max == -1 && errno)
75287530
return posix_error();
75297531
return PyLong_FromLong(max);
75307532
}
@@ -7542,8 +7544,12 @@ static PyObject *
75427544
os_sched_get_priority_min_impl(PyObject *module, int policy)
75437545
/*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
75447546
{
7545-
int min = sched_get_priority_min(policy);
7546-
if (min == -1)
7547+
int min;
7548+
7549+
/* make sure that errno is cleared before the call */
7550+
errno = 0;
7551+
min = sched_get_priority_min(policy);
7552+
if (min == -1 && errno)
75477553
return posix_error();
75487554
return PyLong_FromLong(min);
75497555
}

0 commit comments

Comments
 (0)