summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 002b378..bbae2b1 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -5952,6 +5952,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;
}