Skip to content

Commit

Permalink
[3.6] bpo-30769: Fix reference leak introduced in 7770394 (GH-2416) (#…
Browse files Browse the repository at this point in the history
…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 a7874c7)
  • Loading branch information
emilyemorehouse authored and serhiy-storchaka committed Jun 27, 2017
1 parent 8047f02 commit 2d348f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Misc/ACKS
Expand Up @@ -1590,6 +1590,7 @@ Andi Vajda
Case Van Horsen
John Mark Vandenberg
Kyle VanderBeek
Eric N. Vander Weele
Andrew Vant
Atul Varma
Dmitry Vasiliev
Expand Down
4 changes: 4 additions & 0 deletions Modules/posixmodule.c
Expand Up @@ -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);
Expand All @@ -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),
Expand Down

0 comments on commit 2d348f7

Please sign in to comment.