mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
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:
parent
b2c7cca0cf
commit
198b291df7
5 changed files with 31 additions and 352 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue