Skip to content

Commit 3c42321

Browse files
committed
handle null result
1 parent d54374d commit 3c42321

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
@@ -4536,7 +4536,16 @@ static PyObject * Admin_c_SingleGroupResult_to_py(const rd_kafka_group_result_t
45364536

45374537
kwargs = PyDict_New();
45384538

4539-
cfl_PyDict_SetString(kwargs, "group_id", rd_kafka_group_result_name(c_group_result_response));
4539+
/* Safely handle potential NULL group name from librdkafka */
4540+
const char *group_name = rd_kafka_group_result_name(c_group_result_response);
4541+
if (!group_name) {
4542+
cfl_PyErr_Format(RD_KAFKA_RESP_ERR__INVALID_ARG,
4543+
"Received NULL group name from librdkafka");
4544+
Py_DECREF(kwargs);
4545+
Py_DECREF(GroupResult_type);
4546+
return NULL;
4547+
}
4548+
cfl_PyDict_SetString(kwargs, "group_id", group_name);
45404549

45414550
c_topic_partition_offset_list = rd_kafka_group_result_partitions(c_group_result_response);
45424551
if(c_topic_partition_offset_list) {

0 commit comments

Comments
 (0)