diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-10-22 09:44:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 09:44:18 (GMT) |
commit | 8a9463f2d4044506910e26a8ed42e2bc9fc3e0f8 (patch) | |
tree | f1a801e5dd84329f46c82d6512f7d27e412d3c2d /Modules/_testmultiphase.c | |
parent | c8ba47b5518f83b5766fefe6f68557b5033e1d70 (diff) | |
download | cpython-8a9463f2d4044506910e26a8ed42e2bc9fc3e0f8.zip cpython-8a9463f2d4044506910e26a8ed42e2bc9fc3e0f8.tar.gz cpython-8a9463f2d4044506910e26a8ed42e2bc9fc3e0f8.tar.bz2 |
_testmultiphase: Fix possible ref leak (GH-22881)
This is just test code, but sometimes external contributors reference the code snippets from test code.
`PyModule_AddObject` should be handled in the proper way.
https://docs.python.org/3/c-api/module.html#c.PyModule_AddObject
Diffstat (limited to 'Modules/_testmultiphase.c')
-rw-r--r-- | Modules/_testmultiphase.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index d69ae62..8bba077 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -359,6 +359,7 @@ static int execfunc(PyObject *m) goto fail; } if (PyModule_AddObject(m, "Example", temp) != 0) { + Py_DECREF(temp); goto fail; } @@ -369,6 +370,7 @@ static int execfunc(PyObject *m) goto fail; } if (PyModule_AddObject(m, "error", temp) != 0) { + Py_DECREF(temp); goto fail; } @@ -378,6 +380,7 @@ static int execfunc(PyObject *m) goto fail; } if (PyModule_AddObject(m, "Str", temp) != 0) { + Py_DECREF(temp); goto fail; } @@ -807,6 +810,7 @@ meth_state_access_exec(PyObject *m) return -1; } if (PyModule_AddObject(m, "StateAccessType", temp) != 0) { + Py_DECREF(temp); return -1; } |