This commit is contained in:
Benjamin Peterson 2013-03-04 09:48:30 -05:00
commit 42f382facd
2 changed files with 4 additions and 2 deletions

View File

@ -13,6 +13,8 @@ Core and Builtins
- Issue #17032: The "global" in the "NameError: global name 'x' is not defined" - Issue #17032: The "global" in the "NameError: global name 'x' is not defined"
error message has been removed. Patch by Ram Rachum. error message has been removed. Patch by Ram Rachum.
- Issue #17328: Fix possible refleak in dict.setdefault.
- Issue #17223: array module: Fix a crasher when converting an array containing - Issue #17223: array module: Fix a crasher when converting an array containing
invalid characters (outside range [U+0000; U+10ffff]) to Unicode: invalid characters (outside range [U+0000; U+10ffff]) to Unicode:
repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob. repr(array), str(array) and array.tounicode(). Patch written by Manuel Jacob.

View File

@ -2235,14 +2235,14 @@ dict_setdefault(register PyDictObject *mp, PyObject *args)
return NULL; return NULL;
val = *value_addr; val = *value_addr;
if (val == NULL) { if (val == NULL) {
Py_INCREF(failobj);
Py_INCREF(key);
if (mp->ma_keys->dk_usable <= 0) { if (mp->ma_keys->dk_usable <= 0) {
/* Need to resize. */ /* Need to resize. */
if (insertion_resize(mp) < 0) if (insertion_resize(mp) < 0)
return NULL; return NULL;
ep = find_empty_slot(mp, key, hash, &value_addr); ep = find_empty_slot(mp, key, hash, &value_addr);
} }
Py_INCREF(failobj);
Py_INCREF(key);
MAINTAIN_TRACKING(mp, key, failobj); MAINTAIN_TRACKING(mp, key, failobj);
ep->me_key = key; ep->me_key = key;
ep->me_hash = hash; ep->me_hash = hash;