Bug report
Bug description:
The code below should call Py_DECREF(v); before returning NULL:
| str_path = _get_tcl_lib_path(); | |
| if (str_path == NULL && PyErr_Occurred()) { | |
| return NULL; | |
| } | |
| if (str_path != NULL) { | |
| utf8_path = PyUnicode_AsUTF8String(str_path); | |
| if (utf8_path == NULL) { | |
| return NULL; | |
| } |
The code below shouldn't overwrite the pointer tcl_library_path directly:
| tcl_library_path = PyUnicode_FromString("\\tcl\\tcl" TCL_VERSION); | |
| if (tcl_library_path == NULL) { | |
| Py_DECREF(prefix); | |
| return NULL; | |
| } | |
| tcl_library_path = PyUnicode_Concat(prefix, tcl_library_path); |
I will submit a PR.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
- gh-151337: Avoid possible memory leak in
_tkinter.con Windows. #151340 - [3.14] gh-151337: Avoid possible memory leak in
_tkinter.con Windows. (GH-151340) #151380 - [3.13] gh-151337: Avoid possible memory leak in
_tkinter.con Windows. (GH-151340) #151381 - [3.15] gh-151337: Avoid possible memory leak in
_tkinter.con Windows. (GH-151340) #151379