Skip to content

Commit b27cdc1

Browse files
committed
Fix error checking in sched_get_priority_ functions
python#86005 python#22374
1 parent cb0b009 commit b27cdc1

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
@@ -6726,8 +6726,10 @@ os_sched_get_priority_max_impl(PyObject *module, int policy)
67266726
{
67276727
int max;
67286728

6729+
/* make sure that errno is cleared before the call */
6730+
errno = 0;
67296731
max = sched_get_priority_max(policy);
6730-
if (max < 0)
6732+
if (max == -1 && errno)
67316733
return posix_error();
67326734
return PyLong_FromLong(max);
67336735
}
@@ -6745,8 +6747,12 @@ static PyObject *
67456747
os_sched_get_priority_min_impl(PyObject *module, int policy)
67466748
/*[clinic end generated code: output=7595c1138cc47a6d input=21bc8fa0d70983bf]*/
67476749
{
6748-
int min = sched_get_priority_min(policy);
6749-
if (min < 0)
6750+
int min;
6751+
6752+
/* make sure that errno is cleared before the call */
6753+
errno = 0;
6754+
min = sched_get_priority_min(policy);
6755+
if (min == -1 && errno)
67506756
return posix_error();
67516757
return PyLong_FromLong(min);
67526758
}

0 commit comments

Comments
 (0)