(original) (raw)

changeset: 73103:df24a8b57148 branch: 3.2 parent: 73069:46c82c4141c9 user: Petri Lehtinen petri@digip.org date: Mon Oct 24 21:12:58 2011 +0300 files: Misc/NEWS Objects/dictobject.c description: Issue #13018: Fix reference leaks in error paths in dictobject.c. Patch by Suman Saha. diff -r 46c82c4141c9 -r df24a8b57148 Misc/NEWS --- a/Misc/NEWS Sun Oct 23 21:03:33 2011 +0300 +++ b/Misc/NEWS Mon Oct 24 21:12:58 2011 +0300 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #13018: Fix reference leaks in error paths in dictobject.c. + Patch by Suman Saha. + - Issue #1294232: In a few cases involving metaclass inheritance, the interpreter would sometimes invoke the wrong metaclass when building a new class object. These cases now behave correctly. Patch by Daniel Urban. diff -r 46c82c4141c9 -r df24a8b57148 Objects/dictobject.c --- a/Objects/dictobject.c Sun Oct 23 21:03:33 2011 +0300 +++ b/Objects/dictobject.c Mon Oct 24 21:12:58 2011 +0300 @@ -1314,14 +1314,18 @@ PyObject *key; Py_hash_t hash; - if (dictresize(mp, Py_SIZE(seq))) + if (dictresize(mp, Py_SIZE(seq))) { + Py_DECREF(d); return NULL; + } while (_PyDict_Next(seq, &pos, &key, &oldvalue, &hash)) { Py_INCREF(key); Py_INCREF(value); - if (insertdict(mp, key, hash, value)) + if (insertdict(mp, key, hash, value)) { + Py_DECREF(d); return NULL; + } } return d; } @@ -1332,14 +1336,18 @@ PyObject *key; Py_hash_t hash; - if (dictresize(mp, PySet_GET_SIZE(seq))) + if (dictresize(mp, PySet_GET_SIZE(seq))) { + Py_DECREF(d); return NULL; + } while (_PySet_NextEntry(seq, &pos, &key, &hash)) { Py_INCREF(key); Py_INCREF(value); - if (insertdict(mp, key, hash, value)) + if (insertdict(mp, key, hash, value)) { + Py_DECREF(d); return NULL; + } } return d; } /petri@digip.org