Skip to content

Commit d1b031c

Browse files
authored
gh-114414: Assert PyType_GetModuleByDef result in _threadmodule (#114415)
1 parent 650f9e4 commit d1b031c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Modules/_threadmodule.c

+3
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
901901
}
902902

903903
PyObject *module = PyType_GetModuleByDef(type, &thread_module);
904+
assert(module != NULL);
904905
thread_module_state *state = get_thread_state(module);
905906

906907
localobject *self = (localobject *)type->tp_alloc(type, 0);
@@ -1042,6 +1043,7 @@ static int
10421043
local_setattro(localobject *self, PyObject *name, PyObject *v)
10431044
{
10441045
PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
1046+
assert(module != NULL);
10451047
thread_module_state *state = get_thread_state(module);
10461048

10471049
PyObject *ldict = _ldict(self, state);
@@ -1094,6 +1096,7 @@ static PyObject *
10941096
local_getattro(localobject *self, PyObject *name)
10951097
{
10961098
PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &thread_module);
1099+
assert(module != NULL);
10971100
thread_module_state *state = get_thread_state(module);
10981101

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

0 commit comments

Comments
 (0)