Skip to content

Commit a742913

Browse files
committed
pythongh-114414: Check for NULL after PyType_GetModuleByDef in _threadmodule
1 parent fd49e22 commit a742913

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Modules/_threadmodule.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,9 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
901901
}
902902

903903
PyObject *module = PyType_GetModuleByDef(type, &thread_module);
904+
if (module == NULL) {
905+
return NULL;
906+
}
904907
thread_module_state *state = get_thread_state(module);
905908

906909
localobject *self = (localobject *)type->tp_alloc(type, 0);
@@ -1042,6 +1045,9 @@ static int
10421045
local_setattro(localobject *self, PyObject *name, PyObject *v)
10431046
{
10441047
PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
1048+
if (module == NULL) {
1049+
return NULL;
1050+
}
10451051
thread_module_state *state = get_thread_state(module);
10461052

10471053
PyObject *ldict = _ldict(self, state);
@@ -1094,6 +1100,9 @@ static PyObject *
10941100
local_getattro(localobject *self, PyObject *name)
10951101
{
10961102
PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
1103+
if (module == NULL) {
1104+
return NULL;
1105+
}
10971106
thread_module_state *state = get_thread_state(module);
10981107

10991108
PyObject *ldict = _ldict(self, state);

0 commit comments

Comments
 (0)