diff --git a/Python/marshal.c b/Python/marshal.c index 7d60614e712aef..2e911b7be27593 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; }