File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -308,31 +308,25 @@ pwd_getpwall_impl(PyObject *module)
308308 PyMutex_Lock (& getpwall_mutex );
309309#endif
310310 int failure = 0 ;
311- PyObject * orphan = NULL ;
311+ PyObject * v = NULL ;
312312 setpwent ();
313313 while ((p = getpwent ()) != NULL ) {
314- /* NOTE: Ref counts are not decremented here, as we cannot allow
315- * re-entrancy while holding the mutex. */
316- PyObject * v = mkpwent (module , p );
314+ v = mkpwent (module , p );
317315 if (v == NULL || PyList_Append (d , v ) != 0 ) {
318- orphan = v ;
316+ /* NOTE: cannot dec-ref here, while holding the mutex. */
319317 failure = 1 ;
320318 goto done ;
321319 }
320+ Py_DECREF (v );
322321 }
323322
324323done :
325324 endpwent ();
326325#ifdef Py_GIL_DISABLED
327326 PyMutex_Unlock (& getpwall_mutex );
328327#endif
329- /* Deferred decref on entries created above and added to the list. */
330- Py_ssize_t n = PyList_Size (d );
331- while (-- n >= 0 ) {
332- Py_DECREF (PyList_GetItem (d , n ));
333- }
334328 if (failure ) {
335- Py_XDECREF (orphan );
329+ Py_XDECREF (v );
336330 Py_CLEAR (d );
337331 }
338332 return d ;
You can’t perform that action at this time.
0 commit comments