[Python-checkins] cpython (2.7): Fixed reference leak when read truncated pickle.

serhiy.storchaka python-checkins at python.org
Mon Nov 30 17:33:12 EST 2015


https://hg.python.org/cpython/rev/6a35865eded4
changeset:   99399:6a35865eded4
branch:      2.7
parent:      99393:3d39e1e2dcb3
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Dec 01 00:32:49 2015 +0200
summary:
  Fixed reference leak when read truncated pickle.

files:
  Modules/cPickle.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Modules/cPickle.c b/Modules/cPickle.c
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -3969,7 +3969,10 @@
     if (!module_name)  return -1;
 
     if ((len = self->readline_func(self, &s)) >= 0) {
-        if (len < 2) return bad_readline();
+        if (len < 2) {
+            Py_DECREF(module_name);
+            return bad_readline();
+        }
         if ((class_name = PyString_FromStringAndSize(s, len - 1))) {
             class = find_class(module_name, class_name,
                                self->find_class);

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list