Skip to content

Possible memory leak in _tkinter.c on Windows #151337

@ByteFlowing1337

Description

@ByteFlowing1337

Bug report

Bug description:

The code below should call Py_DECREF(v); before returning NULL:

cpython/Modules/_tkinter.c

Lines 708 to 716 in 0066fd7

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:

cpython/Modules/_tkinter.c

Lines 131 to 136 in 0066fd7

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions