summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-01-07 18:02:53 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2010-01-07 18:02:53 +0000
commit901d81e6724f7685199e669b808fce57a6123d87 (patch)
treec4b0b43272ed65092ea16363997a26e959c53c13
parent93a59653a49d60abaeb69a966370b4277e0f1d3a (diff)
downloadcpython-git-901d81e6724f7685199e669b808fce57a6123d87.tar.gz
Merged revisions 77355 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r77355 | antoine.pitrou | 2010-01-07 18:57:31 +0100 (jeu., 07 janv. 2010) | 18 lines Merged revisions 77352-77354 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77352 | antoine.pitrou | 2010-01-07 18:46:49 +0100 (jeu., 07 janv. 2010) | 5 lines Issue #7455: Fix possible crash in cPickle on invalid input. Patch by Florent Xicluna. ........ r77353 | antoine.pitrou | 2010-01-07 18:49:37 +0100 (jeu., 07 janv. 2010) | 3 lines Fix attribution. Florent actually repackaged and reviewed Victor's patch (sorry!). ........ r77354 | antoine.pitrou | 2010-01-07 18:54:10 +0100 (jeu., 07 janv. 2010) | 3 lines Fix reattribution mistake when fixing attribution mistake! ........ ................
-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 19704ae7ce..7ecc1053d7 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1142,6 +1142,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 ec4fa86eec..eaef3117c3 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -61,6 +61,9 @@ Core and Builtins
Library
-------
+- Issue #7455: Fix possible crash in cPickle on invalid input. Patch by
+ Victor Stinner.
+
- Issue #6511: ZipFile now raises BadZipfile (instead of an IOError) when
opening an empty or very small file.
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 0e6df34bf1..29aed7adb3 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;