]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38823: Fix refleak in marshal init error path (GH-17260)
authorBrandt Bucher <brandtbucher@gmail.com>
Wed, 20 Nov 2019 00:59:32 +0000 (16:59 -0800)
committerVictor Stinner <vstinner@python.org>
Wed, 20 Nov 2019 00:59:32 +0000 (01:59 +0100)
Python/marshal.c

index cb11c8c74ef3a6409dbcae1dfcbb458952c05354..ec6b3dadc02ca703134472ca82f3134e55c94f13 100644 (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;
 }