[Python-checkins] cpython: Fix resource leak in pickle module

christian.heimes python-checkins at python.org
Sat Jun 29 21:37:44 CEST 2013


http://hg.python.org/cpython/rev/ac7bc6700ac3
changeset:   84381:ac7bc6700ac3
user:        Christian Heimes <christian at cheimes.de>
date:        Sat Jun 29 21:37:34 2013 +0200
summary:
  Fix resource leak in pickle module
CID 983309 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable unicode_str going out of scope leaks the storage it points to.

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
@@ -1748,8 +1748,10 @@
                 return -1;
             if (latin1 == NULL) {
                 latin1 = PyUnicode_InternFromString("latin1");
-                if (latin1 == NULL)
+                if (latin1 == NULL) {
+                    Py_DECREF(unicode_str);
                     return -1;
+                }
             }
             reduce_value = Py_BuildValue("(O(OO))",
                                          codecs_encode, unicode_str, latin1);

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


More information about the Python-checkins mailing list