Skip to content

Conversation

BrieucNx
Copy link
Contributor

@BrieucNx BrieucNx commented Jun 13, 2023

There is a memory leak that happens when the rd_kafka_producev function returns an error. This is due to the fact that the function itself takes a pointer to the header struct and takes ownership of it only if no error occurs. If the function returns something else that RD_KAFKA_RESP_ERR_NO_ERROR then the ownership of headers is not taken.

This patch passes the pointer of the header to the produce function and only release the ownership of the memory if the function returned an non error error code.

@BrieucNx BrieucNx changed the title Only release header handle if produce returned no errors [Memory Leak] Only release header handle if producev returned no errors Jun 13, 2023
Copy link
Owner

@mfontanini mfontanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@mfontanini mfontanini merged commit 91ac543 into mfontanini:master Jun 13, 2023
@Light7734
Copy link

Hey when are you guys releasing this? this is not available on any of the conan center recipes, thanks.

@mfontanini
Copy link
Owner

Just released this https://github.com/mfontanini/cppkafka/releases/tag/v0.4.1. Sorry for the delay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants