From ca28eba3d3656bab394f846f9357227d227059ec Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 1 Dec 2015 00:18:23 +0200 Subject: [PATCH] Fixed reference leak when read truncated pickle. --- Modules/_pickle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 6ff16bba7df..c357dcc2194 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -5115,8 +5115,10 @@ load_inst(UnpicklerObject *self) 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);