mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
This commit is contained in:
parent
3d96d522ec
commit
db847bd9ea
1 changed files with 5 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue