mirror of
https://github.com/python/cpython.git
synced 2025-08-25 03:04:55 +00:00
[3.11] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855) (GH-106863)
[3.11] [3.12] gh-86493: Fix possible leaks in some modules initialization (GH-106768) (GH-106855) Fix _ssl, _stat, _testinternalcapi, _threadmodule, cmath, math, posix, time. (cherry picked from commit3e65baee72
). (cherry picked from commita423ddbdea
)
This commit is contained in:
parent
0c47ed7bbf
commit
fced79f91e
10 changed files with 45 additions and 62 deletions
|
@ -658,13 +658,16 @@ PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value)
|
|||
PyModule_GetName(mod));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyDict_SetItemString(dict, name, value)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
return PyDict_SetItemString(dict, name, value);
|
||||
}
|
||||
|
||||
int
|
||||
_PyModule_Add(PyObject *mod, const char *name, PyObject *value)
|
||||
{
|
||||
int res = PyModule_AddObjectRef(mod, name, value);
|
||||
Py_XDECREF(value);
|
||||
return res;
|
||||
}
|
||||
|
||||
int
|
||||
PyModule_AddObject(PyObject *mod, const char *name, PyObject *value)
|
||||
|
@ -679,25 +682,13 @@ PyModule_AddObject(PyObject *mod, const char *name, PyObject *value)
|
|||
int
|
||||
PyModule_AddIntConstant(PyObject *m, const char *name, long value)
|
||||
{
|
||||
PyObject *obj = PyLong_FromLong(value);
|
||||
if (!obj) {
|
||||
return -1;
|
||||
}
|
||||
int res = PyModule_AddObjectRef(m, name, obj);
|
||||
Py_DECREF(obj);
|
||||
return res;
|
||||
return _PyModule_Add(m, name, PyLong_FromLong(value));
|
||||
}
|
||||
|
||||
int
|
||||
PyModule_AddStringConstant(PyObject *m, const char *name, const char *value)
|
||||
{
|
||||
PyObject *obj = PyUnicode_FromString(value);
|
||||
if (!obj) {
|
||||
return -1;
|
||||
}
|
||||
int res = PyModule_AddObjectRef(m, name, obj);
|
||||
Py_DECREF(obj);
|
||||
return res;
|
||||
return _PyModule_Add(m, name, PyUnicode_FromString(value));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue