summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-01 13:18:49 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-01 13:18:49 (GMT)
commitbfafab1849a1f30ee69474a3d275bcaf17844970 (patch)
treeb2605aee7c35c25de9b408ca74d9174aa7282fda /Modules/_pickle.c
parent04926aeb2f88c39a25505e4a0474c6fb735e0f46 (diff)
parenta24b4d260beafb5b45450ff46d7740bea8eaa4a9 (diff)
downloadcpython-bfafab1849a1f30ee69474a3d275bcaf17844970.zip
cpython-bfafab1849a1f30ee69474a3d275bcaf17844970.tar.gz
cpython-bfafab1849a1f30ee69474a3d275bcaf17844970.tar.bz2
Issue #18339: Negative ints keys in unpickler.memo dict no longer cause a
segfault inside the _pickle C extension.
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;
}