Skip to content

Commit

Permalink
Make the error checking more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
kulikjak committed Aug 23, 2022
1 parent 43a478e commit d1a27a6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6812,8 +6812,10 @@ os_sched_get_priority_max_impl(PyObject *module, int policy)
{
int max;

/* make sure that errno is cleared before the call */
errno = 0;
max = sched_get_priority_max(policy);
if (max == -1)
if (max == -1 && errno)
return posix_error();
return PyLong_FromLong(max);
}
Expand All @@ -6831,8 +6833,12 @@ static PyObject *
os_sched_get_priority_min_impl(PyObject *module, int policy)
/*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
{
int min = sched_get_priority_min(policy);
if (min == -1)
int min;

/* make sure that errno is cleared before the call */
errno = 0;
min = sched_get_priority_min(policy);
if (min == -1 && errno)
return posix_error();
return PyLong_FromLong(min);
}
Expand Down

0 comments on commit d1a27a6

Please sign in to comment.