From: Guido van Rossum Date: Thu, 29 Nov 2007 18:23:48 +0000 (+0000) Subject: Fix bug #1517, a possible segfault in lookup(). X-Git-Tag: v2.5.2c1~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbe97b38be8e614783316ec59061caa7d53bf47b;p=python Fix bug #1517, a possible segfault in lookup(). --- diff --git a/Objects/dictobject.c b/Objects/dictobject.c index af0d6f37ae..a315446301 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -272,7 +272,9 @@ lookdict(dictobject *mp, PyObject *key, register long hash) else { if (ep->me_hash == hash) { startkey = ep->me_key; + Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); + Py_DECREF(startkey); if (cmp < 0) return NULL; if (ep0 == mp->ma_table && ep->me_key == startkey) { @@ -302,7 +304,9 @@ lookdict(dictobject *mp, PyObject *key, register long hash) return ep; if (ep->me_hash == hash && ep->me_key != dummy) { startkey = ep->me_key; + Py_INCREF(startkey); cmp = PyObject_RichCompareBool(startkey, key, Py_EQ); + Py_DECREF(startkey); if (cmp < 0) return NULL; if (ep0 == mp->ma_table && ep->me_key == startkey) {