]> granicus.if.org Git - python/commitdiff
Fixed memory leak in marshal.
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 28 Jan 2015 15:10:48 +0000 (17:10 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 28 Jan 2015 15:10:48 +0000 (17:10 +0200)
Python/marshal.c

index bb5faf3297540686a97d09fc10ed6fceef278339..6f0ee5e83edd70bc8de869aad44a7d9b84fb4d02 100644 (file)
@@ -1522,8 +1522,10 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
     wf.depth = 0;
     wf.version = version;
     if (version >= 3) {
-        if ((wf.refs = PyDict_New()) == NULL)
+        if ((wf.refs = PyDict_New()) == NULL) {
+            Py_DECREF(wf.str);
             return NULL;
+        }
     } else
         wf.refs = NULL;
     w_object(x, &wf);