Skip to content

Commit 4b85234

Browse files
committed
Raise runtime error on module import failure to avoid segfault
1 parent 96bc921 commit 4b85234

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

confluent_kafka/src/confluent_kafka.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,13 @@ PyObject *cfl_PyObject_lookup (const char *modulename, const char *typename) {
19591959
return NULL;
19601960
}
19611961

1962+
if (!module) {
1963+
PyErr_Format(PyExc_RuntimeError,
1964+
"Module %s import failed.",
1965+
modulename);
1966+
return NULL;
1967+
}
1968+
19621969
obj = PyObject_GetAttrString(module, typename);
19631970
if (!obj) {
19641971
Py_DECREF(module);

0 commit comments

Comments
 (0)