From 33b671e72450bf4b5a946ce0dde6b7fe21150108 Mon Sep 17 00:00:00 2001 From: Brandt Bucher Date: Tue, 19 Nov 2019 16:59:32 -0800 Subject: bpo-38823: Fix refleak in marshal init error path (GH-17260) --- Python/marshal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Python/marshal.c b/Python/marshal.c index cb11c8c..ec6b3da 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -1829,6 +1829,9 @@ PyMarshal_Init(void) PyObject *mod = PyModule_Create(&marshalmodule); if (mod == NULL) return NULL; - PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION); + if (PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION) < 0) { + Py_DECREF(mod); + return NULL; + } return mod; } -- cgit v0.12