Skip to content

Commit f55a532

Browse files
committed
Make the error checking more robust
1 parent 489388d commit f55a532

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
@@ -7794,8 +7794,10 @@ os_sched_get_priority_max_impl(PyObject *module, int policy)
77947794
{
77957795
int max;
77967796

7797+
/* make sure that errno is cleared before the call */
7798+
errno = 0;
77977799
max = sched_get_priority_max(policy);
7798-
if (max == -1)
7800+
if (max == -1 && errno)
77997801
return posix_error();
78007802
return PyLong_FromLong(max);
78017803
}
@@ -7813,8 +7815,12 @@ static PyObject *
78137815
os_sched_get_priority_min_impl(PyObject *module, int policy)
78147816
/*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
78157817
{
7816-
int min = sched_get_priority_min(policy);
7817-
if (min == -1)
7818+
int min;
7819+
7820+
/* make sure that errno is cleared before the call */
7821+
errno = 0;
7822+
min = sched_get_priority_min(policy);
7823+
if (min == -1 && errno)
78187824
return posix_error();
78197825
return PyLong_FromLong(min);
78207826
}

0 commit comments

Comments
 (0)