diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 6555f1f511c..ac511fcee52 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -7050,8 +7050,10 @@ posix_unsetenv(PyObject *self, PyObject *args) return NULL; err = unsetenv(s1); - if (err) + if (err) { + Py_DECREF(s1); return posix_error(); + } /* Remove the key from posix_putenv_garbage; * this will cause it to be collected. This has to