Skip to content

Commit

Permalink
Fixed a possible memory leak.
Browse files Browse the repository at this point in the history
	modified:   src/sfutil/sf_kafka.c
  • Loading branch information
root authored and eugpermar committed Jul 3, 2013
1 parent 0896ef8 commit dd159ed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/sfutil/sf_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ bool KafkaLog_Flush(KafkaLog* this)
if(this->handler==NULL && BcDaemonMode()){
this->handler = KafkaLog_Open(this->broker);
}
rd_kafka_produce(this->handler, this->topic, 0, RD_KAFKA_OP_F_FREE, this->buf, this->pos);
if(this->handler->rk_state == RD_KAFKA_STATE_DOWN)
free(this->buf);
else
rd_kafka_produce(this->handler, this->topic, 0, RD_KAFKA_OP_F_FREE, this->buf, this->pos);
this->buf = malloc(sizeof(char)*this->maxBuf);

KafkaLog_Reset(this);
Expand Down

0 comments on commit dd159ed

Please sign in to comment.