]> granicus.if.org Git - python/commitdiff
Fix resource leak in pickle module
authorChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 19:37:34 +0000 (21:37 +0200)
committerChristian Heimes <christian@cheimes.de>
Sat, 29 Jun 2013 19:37:34 +0000 (21:37 +0200)
CID 983309 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable unicode_str going out of scope leaks the storage it points to.

Modules/_pickle.c

index 443fbe2e8de6f01c838c024bfba25cf2a5aa40ba..002b37825d0bb12a758641309791eaee922d3161 100644 (file)
@@ -1748,8 +1748,10 @@ save_bytes(PicklerObject *self, PyObject *obj)
                 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);