Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af8d6b9

Browse files
authored
Fixes reference leak (#3457)
1 parent 2b7953d commit af8d6b9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

PC/_findvs.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,26 @@ static PyObject *find_all_instances()
161161
PyObject *version = nullptr;
162162
PyObject *path = nullptr;
163163
PyObject *packages = nullptr;
164+
PyObject *tuple = nullptr;
164165

165166
if (FAILED(hr = inst->QueryInterface(&inst2)) ||
166167
!(name = get_install_name(inst2)) ||
167168
!(version = get_install_version(inst)) ||
168169
!(path = get_install_path(inst)) ||
169170
!(packages = get_installed_packages(inst2)) ||
170-
PyList_Append(res, PyTuple_Pack(4, name, version, path, packages)) < 0)
171+
!(tuple = PyTuple_Pack(4, name, version, path, packages)) ||
172+
PyList_Append(res, tuple) < 0)
171173
goto iter_error;
172174

175+
Py_DECREF(tuple);
176+
Py_DECREF(packages);
177+
Py_DECREF(path);
178+
Py_DECREF(version);
179+
Py_DECREF(name);
173180
continue;
174181
iter_error:
175182
if (inst2) inst2->Release();
183+
Py_XDECREF(tuple);
176184
Py_XDECREF(packages);
177185
Py_XDECREF(path);
178186
Py_XDECREF(version);

0 commit comments

Comments
 (0)