Skip to content

Commit 5c4a652

Browse files
authored
Fix segfault with describe_topics and flaky connection (#1692)
If you call describe_topics on a flaky connection, sometimes the admin client reply has the host set to a null pointer. When this occurs, instead of segfaulting, report the host as None.
1 parent 6cbe8b8 commit 5c4a652

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/confluent_kafka/src/confluent_kafka.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,10 @@ PyObject *c_Node_to_py(const rd_kafka_Node_t *c_node) {
16201620

16211621
cfl_PyDict_SetInt(kwargs, "id", rd_kafka_Node_id(c_node));
16221622
cfl_PyDict_SetInt(kwargs, "port", rd_kafka_Node_port(c_node));
1623-
cfl_PyDict_SetString(kwargs, "host", rd_kafka_Node_host(c_node));
1623+
if (rd_kafka_Node_host(c_node))
1624+
cfl_PyDict_SetString(kwargs, "host", rd_kafka_Node_host(c_node));
1625+
else
1626+
PyDict_SetItemString(kwargs, "host", Py_None);
16241627
if((rack = rd_kafka_Node_rack(c_node)))
16251628
cfl_PyDict_SetString(kwargs, "rack", rack);
16261629

0 commit comments

Comments
 (0)