summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorEmily Morehouse <emily@cuttlesoft.com>2017-06-27 04:59:25 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-06-27 04:59:25 (GMT)
commit2d348f7a723db839aa18ce8213b8663ccb0a3d35 (patch)
treea4a72a15945ca5666def24c95f5ecaff9fad72b3 /Modules
parent8047f02a4b0db81cb023df1f5ce4cc1c42d17821 (diff)
downloadcpython-2d348f7a723db839aa18ce8213b8663ccb0a3d35.zip
cpython-2d348f7a723db839aa18ce8213b8663ccb0a3d35.tar.gz
cpython-2d348f7a723db839aa18ce8213b8663ccb0a3d35.tar.bz2
[3.6] bpo-30769: Fix reference leak introduced in 77703942c59 (GH-2416) (#2425)
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 <ericvw@gmail.com> (cherry picked from commit a7874c73c0c729bbec2fd4b077bd0eec276cfff4)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/posixmodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 0337890..bf82543 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4823,6 +4823,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);
@@ -4837,6 +4839,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),