summaryrefslogtreecommitdiffstats
path: root/Modules/_functoolsmodule.c
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-11-09 23:56:26 (GMT)
committerYury Selivanov <yury@magic.io>2016-11-09 23:56:26 (GMT)
commit0a66a1cdd61ce7239298e19c938b05ade99cde8a (patch)
treea0c5960f506eb71da05f090f7adf7e0e1ff17271 /Modules/_functoolsmodule.c
parent04c954d2754e917c037c032579ee5aa95da6529e (diff)
parent46a02db90b295bfec1712515e09aeda31bbe84e0 (diff)
downloadcpython-0a66a1cdd61ce7239298e19c938b05ade99cde8a.zip
cpython-0a66a1cdd61ce7239298e19c938b05ade99cde8a.tar.gz
cpython-0a66a1cdd61ce7239298e19c938b05ade99cde8a.tar.bz2
Merge 3.6 (issue #28653)
Diffstat (limited to 'Modules/_functoolsmodule.c')
-rw-r--r--Modules/_functoolsmodule.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index fa5fad3..2269d05 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -793,8 +793,10 @@ infinite_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwd
if (!key)
return NULL;
hash = PyObject_Hash(key);
- if (hash == -1)
+ if (hash == -1) {
+ Py_DECREF(key);
return NULL;
+ }
result = _PyDict_GetItem_KnownHash(self->cache, key, hash);
if (result) {
Py_INCREF(result);
@@ -849,8 +851,10 @@ bounded_lru_cache_wrapper(lru_cache_object *self, PyObject *args, PyObject *kwds
if (!key)
return NULL;
hash = PyObject_Hash(key);
- if (hash == -1)
+ if (hash == -1) {
+ Py_DECREF(key);
return NULL;
+ }
link = (lru_list_elem *)_PyDict_GetItem_KnownHash(self->cache, key, hash);
if (link) {
lru_cache_extricate_link(link);