mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Issue #18339: Negative ints keys in unpickler.memo dict no longer cause a
segfault inside the _pickle C extension.
This commit is contained in:
parent
8a0b7756e2
commit
a24b4d260b
3 changed files with 15 additions and 0 deletions
|
|
@ -5931,6 +5931,11 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj)
|
|||
idx = PyLong_AsSsize_t(key);
|
||||
if (idx == -1 && PyErr_Occurred())
|
||||
goto error;
|
||||
if (idx < 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"memos key must be positive integers.");
|
||||
goto error;
|
||||
}
|
||||
if (_Unpickler_MemoPut(self, idx, value) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue