Skip to content

Commit 3cef461

Browse files
authored
Handle null group name to prevent segfault in Admin list_consumer_group_offsets() (#2118)
* update * update
1 parent 7fa7655 commit 3cef461

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/confluent_kafka/src/Admin.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4582,7 +4582,16 @@ static PyObject * Admin_c_SingleGroupResult_to_py(const rd_kafka_group_result_t
45824582

45834583
kwargs = PyDict_New();
45844584

4585-
cfl_PyDict_SetString(kwargs, "group_id", rd_kafka_group_result_name(c_group_result_response));
4585+
/* Safely handle potential NULL group name from librdkafka */
4586+
const char *group_name = rd_kafka_group_result_name(c_group_result_response);
4587+
if (!group_name) {
4588+
cfl_PyErr_Format(RD_KAFKA_RESP_ERR__FAIL,
4589+
"Received NULL group name from librdkafka");
4590+
Py_DECREF(kwargs);
4591+
Py_DECREF(GroupResult_type);
4592+
return NULL;
4593+
}
4594+
cfl_PyDict_SetString(kwargs, "group_id", group_name);
45864595

45874596
c_topic_partition_offset_list = rd_kafka_group_result_partitions(c_group_result_response);
45884597
if(c_topic_partition_offset_list) {

0 commit comments

Comments
 (0)