From 6343c43d05a6176a7569c3159497d4a0a8a645a7 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 25 May 2025 18:24:48 +0200 Subject: [PATCH] Fix crash in get_member_id() if client group is not initialized Since in this case rd_kafka_memberid() return NULL, and std::string cannot be constructed from NULL [1]. [1]: https://github.com/llvm/llvm-project/blob/fe51d8ae5772626ef8237c33e0911695cf4f07db/libcxx/include/string#L1051-L1055 --- src/consumer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/consumer.cpp b/src/consumer.cpp index a244c370..c328ab28 100644 --- a/src/consumer.cpp +++ b/src/consumer.cpp @@ -241,6 +241,8 @@ TopicPartitionList Consumer::get_assignment() const { string Consumer::get_member_id() const { char* memberid_ptr = rd_kafka_memberid(get_handle()); + if (memberid_ptr == nullptr) + return string(); string memberid_string = memberid_ptr; rd_kafka_mem_free(nullptr, memberid_ptr); return memberid_string;