From 63f09e7628bd72f1bb2106226655b1f775757806 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 20 Nov 2019 02:15:22 -0800 Subject: [PATCH] bpo-38823: Fix refleak in marshal init error path (GH-17260) (cherry picked from commit 33b671e72450bf4b5a946ce0dde6b7fe21150108) Co-authored-by: Brandt Bucher --- Python/marshal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Python/marshal.c b/Python/marshal.c index 7d60614e712a..2e911b7be275 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -1860,6 +1860,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; } -- 2.47.3