summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-11-20 20:35:45 (GMT)
committerGuido van Rossum <guido@python.org>1997-11-20 20:35:45 (GMT)
commitdb847bd9ea6df19ca4a81558f4cc6d3622aecf24 (patch)
tree31c442e8d4163ac0c63b949124437ead404145fd /Python
parent3d96d522ecc6adfc77fe3f1f6a47f11655c9a304 (diff)
downloadcpython-db847bd9ea6df19ca4a81558f4cc6d3622aecf24.zip
cpython-db847bd9ea6df19ca4a81558f4cc6d3622aecf24.tar.gz
cpython-db847bd9ea6df19ca4a81558f4cc6d3622aecf24.tar.bz2
Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
Diffstat (limited to 'Python')
-rw-r--r--Python/modsupport.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 12ecaf6..0ddc300 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -169,6 +169,7 @@ do_mkdict(p_format, p_va, endchar, n)
return NULL;
for (i = 0; i < n; i+= 2) {
PyObject *k, *v;
+ int err;
k = do_mkvalue(p_format, p_va);
if (k == NULL) {
Py_DECREF(d);
@@ -180,9 +181,10 @@ do_mkdict(p_format, p_va, endchar, n)
Py_DECREF(d);
return NULL;
}
- if (PyDict_SetItem(d, k, v) < 0) {
- Py_DECREF(k);
- Py_DECREF(v);
+ err = PyDict_SetItem(d, k, v);
+ Py_DECREF(k);
+ Py_DECREF(v);
+ if (err < 0) {
Py_DECREF(d);
return NULL;
}