From: Brandt Bucher Date: Wed, 20 Nov 2019 00:59:32 +0000 (-0800) Subject: bpo-38823: Fix refleak in marshal init error path (GH-17260) X-Git-Tag: v3.9.0a2~180 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33b671e72450bf4b5a946ce0dde6b7fe21150108;p=thirdparty%2FPython%2Fcpython.git bpo-38823: Fix refleak in marshal init error path (GH-17260) --- diff --git a/Python/marshal.c b/Python/marshal.c index cb11c8c74ef3..ec6b3dadc02c 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; }