Close #14205: dict lookup raises a RuntimeError if the dict is modified during

a lookup.

"if you want to make a sandbox on top of CPython, you have to fix segfaults"
so let's fix segfaults!
This commit is contained in:
Victor Stinner 2012-03-06 01:03:13 +01:00
parent b2c7cca0cf
commit 198b291df7
5 changed files with 31 additions and 352 deletions

View file

@ -347,12 +347,9 @@ lookdict(PyDictObject *mp, PyObject *key, register Py_hash_t hash)
return ep;
}
else {
/* The compare did major nasty stuff to the
* dict: start over.
* XXX A clever adversary could prevent this
* XXX from terminating.
*/
return lookdict(mp, key, hash);
PyErr_SetString(PyExc_RuntimeError,
"dictionary changed size during lookup");
return NULL;
}
}
freeslot = NULL;
@ -379,12 +376,9 @@ lookdict(PyDictObject *mp, PyObject *key, register Py_hash_t hash)
return ep;
}
else {
/* The compare did major nasty stuff to the
* dict: start over.
* XXX A clever adversary could prevent this
* XXX from terminating.
*/
return lookdict(mp, key, hash);
PyErr_SetString(PyExc_RuntimeError,
"dictionary changed size during lookup");
return NULL;
}
}
else if (ep->me_key == dummy && freeslot == NULL)