diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index be99be86516a..3197a0d2d8df 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -2396,6 +2396,7 @@ posix_listdir(PyObject *self, PyObject *args) } strcpy(namebuf, PyBytes_AsString(opath)); len = PyObject_Size(opath); + Py_DECREF(opath); if (len > 0) { char ch = namebuf[len-1]; if (ch != SEP && ch != ALTSEP && ch != ':')