diff options
author | Steve Dower <steve.dower@microsoft.com> | 2017-09-08 18:35:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-08 18:35:38 (GMT) |
commit | af8d6b90723daa943c5cd0a38ee7564790d8687a (patch) | |
tree | 99e234c794dbd3a4d7aceb472448c740ddef4403 /PC | |
parent | 2b7953d974dbe5adc0937394c93f31c46cf01517 (diff) | |
download | cpython-af8d6b90723daa943c5cd0a38ee7564790d8687a.zip cpython-af8d6b90723daa943c5cd0a38ee7564790d8687a.tar.gz cpython-af8d6b90723daa943c5cd0a38ee7564790d8687a.tar.bz2 |
Fixes reference leak (#3457)
Diffstat (limited to 'PC')
-rw-r--r-- | PC/_findvs.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/PC/_findvs.cpp b/PC/_findvs.cpp index 6c66011..dd7c1fc 100644 --- a/PC/_findvs.cpp +++ b/PC/_findvs.cpp @@ -161,18 +161,26 @@ static PyObject *find_all_instances() PyObject *version = nullptr; PyObject *path = nullptr; PyObject *packages = nullptr; + PyObject *tuple = nullptr; if (FAILED(hr = inst->QueryInterface(&inst2)) || !(name = get_install_name(inst2)) || !(version = get_install_version(inst)) || !(path = get_install_path(inst)) || !(packages = get_installed_packages(inst2)) || - PyList_Append(res, PyTuple_Pack(4, name, version, path, packages)) < 0) + !(tuple = PyTuple_Pack(4, name, version, path, packages)) || + PyList_Append(res, tuple) < 0) goto iter_error; + Py_DECREF(tuple); + Py_DECREF(packages); + Py_DECREF(path); + Py_DECREF(version); + Py_DECREF(name); continue; iter_error: if (inst2) inst2->Release(); + Py_XDECREF(tuple); Py_XDECREF(packages); Py_XDECREF(path); Py_XDECREF(version); |