[Python-checkins] cpython (merge 3.5 -> default): Fixed reference leak when read truncated pickle.

serhiy.storchaka python-checkins at python.org
Mon Nov 30 17:21:14 EST 2015


https://hg.python.org/cpython/rev/0a36c8fe4703
changeset:   99398:0a36c8fe4703
parent:      99395:962086677306
parent:      99397:f0469025df14
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Dec 01 00:20:49 2015 +0200
summary:
  Fixed reference leak when read truncated pickle.

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


diff --git a/Modules/_pickle.c b/Modules/_pickle.c
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -5247,8 +5247,10 @@
         return -1;
 
     if ((len = _Unpickler_Readline(self, &s)) >= 0) {
-        if (len < 2)
+        if (len < 2) {
+            Py_DECREF(module_name);
             return bad_readline();
+        }
         class_name = PyUnicode_DecodeASCII(s, len - 1, "strict");
         if (class_name != NULL) {
             cls = find_class(self, module_name, class_name);

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


More information about the Python-checkins mailing list