[Python-checkins] bpo-38823: Fix refleak in marshal init error path (GH-17260)

Miss Islington (bot) webhook-mailer at python.org
Wed Nov 20 05:16:11 EST 2019


https://github.com/python/cpython/commit/2ea4c37c1ecf05a8495211d55ed6888439b1b9cf
commit: 2ea4c37c1ecf05a8495211d55ed6888439b1b9cf
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-11-20T02:16:02-08:00
summary:

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

(cherry picked from commit 33b671e72450bf4b5a946ce0dde6b7fe21150108)

Co-authored-by: Brandt Bucher <brandtbucher at gmail.com>

files:
M Python/marshal.c

diff --git a/Python/marshal.c b/Python/marshal.c
index b2daff2c8a3be..c6a06e8c23976 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -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;
 }



More information about the Python-checkins mailing list