Skip to content

Commit d1a27a6

Browse files
committed
Make the error checking more robust
1 parent 43a478e commit d1a27a6

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
@@ -6812,8 +6812,10 @@ os_sched_get_priority_max_impl(PyObject *module, int policy)
68126812
{
68136813
int max;
68146814

6815+
/* make sure that errno is cleared before the call */
6816+
errno = 0;
68156817
max = sched_get_priority_max(policy);
6816-
if (max == -1)
6818+
if (max == -1 && errno)
68176819
return posix_error();
68186820
return PyLong_FromLong(max);
68196821
}
@@ -6831,8 +6833,12 @@ static PyObject *
68316833
os_sched_get_priority_min_impl(PyObject *module, int policy)
68326834
/*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
68336835
{
6834-
int min = sched_get_priority_min(policy);
6835-
if (min == -1)
6836+
int min;
6837+
6838+
/* make sure that errno is cleared before the call */
6839+
errno = 0;
6840+
min = sched_get_priority_min(policy);
6841+
if (min == -1 && errno)
68366842
return posix_error();
68376843
return PyLong_FromLong(min);
68386844
}

0 commit comments

Comments
 (0)