Fix bug #1517, a possible segfault in lookup().

This commit is contained in:
Guido van Rossum 2007-11-29 18:23:48 +00:00
parent 14fbf29692
commit dbe97b38be
1 changed files with 4 additions and 0 deletions

View File

@ -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) {