summaryrefslogtreecommitdiffstats
path: root/Python/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/marshal.c')
-rw-r--r--Python/marshal.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index bb5faf3..6f0ee5e 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -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);