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.
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 thatRD_KAFKA_RESP_ERR_NO_ERROR
then the ownership ofheaders
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.