]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix upsizing of marks stack in pickle module. (GH-8860)
authorSergey Fedoseev <fedoseev.sergey@gmail.com>
Sat, 25 Aug 2018 07:54:40 +0000 (12:54 +0500)
committerSerhiy Storchaka <storchaka@gmail.com>
Sat, 25 Aug 2018 07:54:40 +0000 (10:54 +0300)
Previously marks stack was upsized even there was space for additional item.

Lib/test/test_pickle.py
Modules/_pickle.c

index 0051a0118a3f218d08ad7226c8a6c8482d57d339..b4bce7e6acebcd8d139fd0a0af0291acb4fcc714 100644 (file)
@@ -309,9 +309,9 @@ if has_c_implementation:
                 return data
             check_unpickler(recurse(0), 32, 0)
             check_unpickler(recurse(1), 32, 20)
-            check_unpickler(recurse(20), 32, 58)
-            check_unpickler(recurse(50), 64, 58)
-            check_unpickler(recurse(100), 128, 134)
+            check_unpickler(recurse(20), 32, 20)
+            check_unpickler(recurse(50), 64, 60)
+            check_unpickler(recurse(100), 128, 140)
 
             u = unpickler(io.BytesIO(pickle.dumps('a', 0)),
                           encoding='ASCII', errors='strict')
index 517c99e1746b8867953189bb710731f25a5e9d91..39628fcef5d5c4c76149b23c99a87b79ce5dc211 100644 (file)
@@ -6288,7 +6288,7 @@ load_mark(UnpicklerObject *self)
      * mark stack.
      */
 
-    if ((self->num_marks + 1) >= self->marks_size) {
+    if (self->num_marks >= self->marks_size) {
         size_t alloc;
 
         /* Use the size_t type to check for overflow. */