Skip to content

Commit 63f09e7

Browse files
bpo-38823: Fix refleak in marshal init error path (GH-17260)
(cherry picked from commit 33b671e) Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
1 parent 755caaa commit 63f09e7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/marshal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,9 @@ PyMarshal_Init(void)
18601860
PyObject *mod = PyModule_Create(&marshalmodule);
18611861
if (mod == NULL)
18621862
return NULL;
1863-
PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION);
1863+
if (PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION) < 0) {
1864+
Py_DECREF(mod);
1865+
return NULL;
1866+
}
18641867
return mod;
18651868
}

0 commit comments

Comments
 (0)