Skip to content

Commit daa2cd1

Browse files
committed
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
1 parent f56b2fe commit daa2cd1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/consumer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ TopicPartitionList Consumer::get_assignment() const {
241241

242242
string Consumer::get_member_id() const {
243243
char* memberid_ptr = rd_kafka_memberid(get_handle());
244+
if (memberid_ptr == nullptr)
245+
return string();
244246
string memberid_string = memberid_ptr;
245247
rd_kafka_mem_free(nullptr, memberid_ptr);
246248
return memberid_string;

0 commit comments

Comments
 (0)