Skip to content

Commit d0b17c6

Browse files
committed
fix stupid direct return out of critical section
1 parent 060100f commit d0b17c6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Modules/arraymodule.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,12 @@ getarrayitem_locked(PyObject *op, Py_ssize_t i)
814814
}
815815
#endif
816816
if (!valid_index(i, Py_SIZE(op))) {
817-
return NULL;
817+
ret = NULL;
818+
}
819+
else {
820+
arrayobject *ap = (arrayobject *)op;
821+
ret = getarrayitem(op, i, ap->ob_item);
818822
}
819-
arrayobject *ap = (arrayobject *)op;
820-
ret = getarrayitem(op, i, ap->ob_item);
821823
Py_END_CRITICAL_SECTION();
822824
return ret;
823825
}
@@ -844,6 +846,8 @@ getarrayitem_maybe_locked(PyObject *op, Py_ssize_t i)
844846
return NULL;
845847
}
846848
return getarrayitem(op, i, items);
849+
/* Could check size again here to make sure it hasn't changed during get,
850+
but not sure would add anything of value. */
847851
}
848852

849853
#else // Py_GIL_DISABLED

0 commit comments

Comments
 (0)