]> granicus.if.org Git - python/commitdiff
Issue #24583: Fix refcount leak.
authorRaymond Hettinger <python@rcn.com>
Mon, 20 Jul 2015 05:23:32 +0000 (01:23 -0400)
committerRaymond Hettinger <python@rcn.com>
Mon, 20 Jul 2015 05:23:32 +0000 (01:23 -0400)
Objects/setobject.c

index fbac596e215ca17239e50b56bfc362dfd7ad5aa9..83bff8176c80beada8861799ecf65380494250b3 100644 (file)
@@ -223,9 +223,13 @@ _set_add_entry(PySetObject *so, PyObject *key, Py_hash_t hash)
     entry->hash = hash;
     if ((size_t)so->fill*3 < mask*2)
         return 0;
-    return set_table_resize(so, so->used);
+    if (!set_table_resize(so, so->used))
+        return 0;
+    Py_INCREF(key);
+    return -1;
 
   found_active:
+    Py_DECREF(key);
     return 0;
 }