summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/pickletester.py3
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_pickle.c2
3 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 759c986..7ded8b6 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1139,6 +1139,9 @@ class AbstractPickleModuleTests(unittest.TestCase):
# Test issue4298
s = bytes([0x58, 0, 0, 0, 0x54])
self.assertRaises(EOFError, pickle.loads, s)
+ # Test issue7455
+ s = b'0'
+ self.assertRaises(pickle.UnpicklingError, pickle.loads, s)
class AbstractPersistentPicklerTests(unittest.TestCase):
diff --git a/Misc/NEWS b/Misc/NEWS
index c78c960..23fec21 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -194,6 +194,9 @@ C-API
Library
-------
+- Issue #7455: Fix possible crash in cPickle on invalid input. Patch by
+ Victor Stinner.
+
- Issue #1628205: Socket file objects returned by socket.socket.makefile() now
properly handles EINTR within the read, readline, write & flush methods.
The socket.sendall() method now properly handles interrupted system calls.
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 0e6df34..29aed7a 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3729,7 +3729,7 @@ load_pop(UnpicklerObject *self)
*/
if (self->num_marks > 0 && self->marks[self->num_marks - 1] == len) {
self->num_marks--;
- } else if (len >= 0) {
+ } else if (len > 0) {
len--;
Py_DECREF(self->stack->data[len]);
self->stack->length = len;