Issue #18339: Negative ints keys in unpickler.memo dict no longer cause a

segfault inside the _pickle C extension.
This commit is contained in:
Christian Heimes 2013-07-01 15:17:45 +02:00
parent 8a0b7756e2
commit a24b4d260b
3 changed files with 15 additions and 0 deletions

View file

@ -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;
}