Skip to content

Commit 6b78b29

Browse files
committed
Address reviewer feedback
1 parent d30a139 commit 6b78b29

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

Modules/pwdmodule.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,12 @@ pwd_getpwall_impl(PyObject *module)
326326
#ifdef Py_GIL_DISABLED
327327
PyMutex_Unlock(&getpwall_mutex);
328328
#endif
329-
/* Deferred decref on entries created above and added to the list */
330-
Py_ssize_t n = PyList_Size(d);
331-
for (Py_ssize_t i = 0; i < n; ++i) {
332-
PyObject *entry = PyList_GetItem(d, i);
333-
Py_DECREF(entry);
329+
/* Deferred decref on entries created above and added to the list. */
330+
Py_ssize_t n = PyList_GET_SIZE(d);
331+
while (--n >= 0) {
332+
Py_DECREF(PyList_GET_ITEM(d, n));
334333
}
335334
if (failure) {
336-
/* If there was a failure we might have created an entry but not added
337-
* it: dec-ref that, if it exists, before clearing the list. */
338335
Py_XDECREF(orphan);
339336
Py_CLEAR(d);
340337
}

0 commit comments

Comments
 (0)