From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 18 Nov 2019 15:09:43 +0000 (-0800) Subject: bpo-38823: Clean up refleaks in _tkinter initialization. (GH-17206) X-Git-Tag: v3.7.6rc1~45 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e4d0312101cc2bc44a9549974d4a25f80e1dc12;p=thirdparty%2FPython%2Fcpython.git bpo-38823: Clean up refleaks in _tkinter initialization. (GH-17206) https://bugs.python.org/issue38823 (cherry picked from commit 289cf0fbf78c4f38c38ac71ac8b772be7ec2672f) Co-authored-by: Brandt Bucher --- diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 8ea302ea639f..bc648dc07466 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -3552,11 +3552,13 @@ PyInit__tkinter(void) if (!ret && GetLastError() == ERROR_ENVVAR_NOT_FOUND) { str_path = _get_tcl_lib_path(); if (str_path == NULL && PyErr_Occurred()) { + Py_DECREF(m); return NULL; } if (str_path != NULL) { wcs_path = PyUnicode_AsWideCharString(str_path, NULL); if (wcs_path == NULL) { + Py_DECREF(m); return NULL; } SetEnvironmentVariableW(L"TCL_LIBRARY", wcs_path);