From a7874c73c0c729bbec2fd4b077bd0eec276cfff4 Mon Sep 17 00:00:00 2001 From: "Eric N. Vander Weele" Date: Mon, 26 Jun 2017 21:35:20 -0400 Subject: [PATCH] bpo-30769: Fix reference leak introduced in 77703942c59 (#2416) New error condition paths were introduced, which did not decrement `key2` and `val2` objects. Therefore, decrement references before jumping to the error label. Signed-off-by: Eric N. Vander Weele --- Misc/ACKS | 1 + Modules/posixmodule.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Misc/ACKS b/Misc/ACKS index 89cd1fa10a0..a6d1e0ffaf4 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1611,6 +1611,7 @@ Andi Vajda Case Van Horsen John Mark Vandenberg Kyle VanderBeek +Eric N. Vander Weele Andrew Vant Atul Varma Dmitry Vasiliev diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 79efb4c11bb..1c75eae1ca6 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4900,6 +4900,8 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr) PyUnicode_FindChar(key2, '=', 1, PyUnicode_GET_LENGTH(key2), 1) != -1) { PyErr_SetString(PyExc_ValueError, "illegal environment variable name"); + Py_DECREF(key2); + Py_DECREF(val2); goto error; } keyval = PyUnicode_FromFormat("%U=%U", key2, val2); @@ -4914,6 +4916,8 @@ parse_envlist(PyObject* env, Py_ssize_t *envc_ptr) strchr(PyBytes_AS_STRING(key2) + 1, '=') != NULL) { PyErr_SetString(PyExc_ValueError, "illegal environment variable name"); + Py_DECREF(key2); + Py_DECREF(val2); goto error; } keyval = PyBytes_FromFormat("%s=%s", PyBytes_AS_STRING(key2),