bpo-38823: Fix refleak in marshal init error path (GH-17260)

This commit is contained in:
Brandt Bucher 2019-11-19 16:59:32 -08:00 committed by Victor Stinner
parent 2e96906da7
commit 33b671e724
1 changed files with 4 additions and 1 deletions

View File

@ -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;
}