[3.8] bpo-38168: Fix a possbile refleak in setint() of mmapmodule.c (GH-16136) (GH-16174)

(cherry picked from commit 56a45142e7)


Co-authored-by: Hai Shi <shihai1992@gmail.com>

https://bugs.python.org/issue38168



Automerge-Triggered-By: @zhangyangyu
This commit is contained in:
Miss Islington (bot) 2019-09-15 23:26:57 -07:00 committed by GitHub
parent 346b7c928b
commit 322309efe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1468,7 +1468,8 @@ static void
setint(PyObject *d, const char *name, long value)
{
PyObject *o = PyLong_FromLong(value);
if (o && PyDict_SetItemString(d, name, o) == 0) {
if (o) {
PyDict_SetItemString(d, name, o);
Py_DECREF(o);
}
}