mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
Issue #13018: Fix reference leaks in error paths in dictobject.c.
Patch by Suman Saha.
This commit is contained in:
parent
c8065e46fe
commit
8ffbab8d02
2 changed files with 15 additions and 4 deletions
|
|
@ -9,6 +9,9 @@ What's New in Python 2.7.3?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #13018: Fix reference leaks in error paths in dictobject.c.
|
||||||
|
Patch by Suman Saha.
|
||||||
|
|
||||||
- Issue #12604: VTRACE macro expanded to no-op in _sre.c to avoid compiler
|
- Issue #12604: VTRACE macro expanded to no-op in _sre.c to avoid compiler
|
||||||
warnings. Patch by Josh Triplett and Petri Lehtinen.
|
warnings. Patch by Josh Triplett and Petri Lehtinen.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1335,14 +1335,18 @@ dict_fromkeys(PyObject *cls, PyObject *args)
|
||||||
PyObject *key;
|
PyObject *key;
|
||||||
long hash;
|
long hash;
|
||||||
|
|
||||||
if (dictresize(mp, Py_SIZE(seq)))
|
if (dictresize(mp, Py_SIZE(seq))) {
|
||||||
|
Py_DECREF(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
|
while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) {
|
||||||
Py_INCREF(key);
|
Py_INCREF(key);
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
if (insertdict(mp, key, hash, value))
|
if (insertdict(mp, key, hash, value)) {
|
||||||
|
Py_DECREF(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
@ -1353,14 +1357,18 @@ dict_fromkeys(PyObject *cls, PyObject *args)
|
||||||
PyObject *key;
|
PyObject *key;
|
||||||
long hash;
|
long hash;
|
||||||
|
|
||||||
if (dictresize(mp, PySet_GET_SIZE(seq)))
|
if (dictresize(mp, PySet_GET_SIZE(seq))) {
|
||||||
|
Py_DECREF(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
|
while (_PySet_NextEntry(seq, &pos, &key, &hash)) {
|
||||||
Py_INCREF(key);
|
Py_INCREF(key);
|
||||||
Py_INCREF(value);
|
Py_INCREF(value);
|
||||||
if (insertdict(mp, key, hash, value))
|
if (insertdict(mp, key, hash, value)) {
|
||||||
|
Py_DECREF(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue