diff options
author | Collin Winter <collinw@gmail.com> | 2009-05-26 16:53:41 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2009-05-26 16:53:41 (GMT) |
commit | 8ca69de23772af21a2e697ab7e73a72e29ef178d (patch) | |
tree | 54e028000dae9438b3b4dec93e1333baafaa07e8 /Modules | |
parent | 7d5285ec79ef0f907ade0f110a008694441a97e3 (diff) | |
download | cpython-8ca69de23772af21a2e697ab7e73a72e29ef178d.zip cpython-8ca69de23772af21a2e697ab7e73a72e29ef178d.tar.gz cpython-8ca69de23772af21a2e697ab7e73a72e29ef178d.tar.bz2 |
Merged revisions 72930 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72930 | collin.winter | 2009-05-25 21:12:39 -0700 (Mon, 25 May 2009) | 1 line
Issue 5794: fix cPickle's unpickling of recursive tuples.
........
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_pickle.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 6f33c25..3ad55b5 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -3639,25 +3639,24 @@ load_binpersid(UnpicklerObject *self) static int load_pop(UnpicklerObject *self) { - int len; - - if ((len = self->stack->length) <= 0) - return stack_underflow(); + int len = self->stack->length; /* Note that we split the (pickle.py) stack into two stacks, * an object stack and a mark stack. We have to be clever and * pop the right one. We do this by looking at the top of the - * mark stack. + * mark stack first, and only signalling a stack underflow if + * the object stack is empty and the mark stack doesn't match + * our expectations. */ - - if ((self->num_marks > 0) && (self->marks[self->num_marks - 1] == len)) + if (self->num_marks > 0 && self->marks[self->num_marks - 1] == len) { self->num_marks--; - else { + } else if (len >= 0) { len--; Py_DECREF(self->stack->data[len]); self->stack->length = len; + } else { + return stack_underflow(); } - return 0; } |