]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38823: Fix refleak in marshal init error path (GH-17260)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 20 Nov 2019 10:15:22 +0000 (02:15 -0800)
committerGitHub <noreply@github.com>
Wed, 20 Nov 2019 10:15:22 +0000 (02:15 -0800)
(cherry picked from commit 33b671e72450bf4b5a946ce0dde6b7fe21150108)

Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
Python/marshal.c

index 7d60614e712aef13617fd5eb23bbb2ca47a7c15e..2e911b7be27593f6badbe08a01e02c00be33a194 100644 (file)
@@ -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;
 }