summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 8a98f51..d3bc420 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -448,8 +448,8 @@ Pdata_grow(Pdata *self)
static PyObject *
Pdata_pop(Pdata *self)
{
- PickleState *st = _Pickle_GetGlobalState();
if (Py_SIZE(self) == 0) {
+ PickleState *st = _Pickle_GetGlobalState();
PyErr_SetString(st->UnpicklingError, "bad pickle data");
return NULL;
}
@@ -5079,6 +5079,9 @@ load_obj(UnpicklerObject *self)
if ((i = marker(self)) < 0)
return -1;
+ if (Py_SIZE(self->stack) - i < 1)
+ return stack_underflow();
+
args = Pdata_poptuple(self->stack, i + 1);
if (args == NULL)
return -1;
@@ -5737,13 +5740,18 @@ do_append(UnpicklerObject *self, Py_ssize_t x)
static int
load_append(UnpicklerObject *self)
{
+ if (Py_SIZE(self->stack) - 1 <= 0)
+ return stack_underflow();
return do_append(self, Py_SIZE(self->stack) - 1);
}
static int
load_appends(UnpicklerObject *self)
{
- return do_append(self, marker(self));
+ Py_ssize_t i = marker(self);
+ if (i < 0)
+ return -1;
+ return do_append(self, i);
}
static int
@@ -5793,7 +5801,10 @@ load_setitem(UnpicklerObject *self)
static int
load_setitems(UnpicklerObject *self)
{
- return do_setitems(self, marker(self));
+ Py_ssize_t i = marker(self);
+ if (i < 0)
+ return -1;
+ return do_setitems(self, i);
}
static int
@@ -5803,6 +5814,8 @@ load_additems(UnpicklerObject *self)
Py_ssize_t mark, len, i;
mark = marker(self);
+ if (mark < 0)
+ return -1;
len = Py_SIZE(self->stack);
if (mark > len || mark <= 0)
return stack_underflow();