Skip to content

Commit

Permalink
file_out: Fix leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
xkaraman committed Feb 27, 2024
1 parent 967fb30 commit 8af509a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/modules/file_out/file_out.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,14 @@ static void fo_log_writer_process(int rank)
LM_ERR("Failed to flush file with err {%s}\n", strerror(errno));
}

if(log_message.prefix != NULL) {
if(log_message.prefix->s != NULL) {
shm_free(log_message.prefix->s);
}
shm_free(log_message.prefix);
log_message.prefix = NULL;
}

if(log_message.message != NULL) {
if(log_message.message->s != NULL) {
shm_free(log_message.message->s);
Expand Down
14 changes: 13 additions & 1 deletion src/modules/file_out/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,19 @@ void fo_free_queue(fo_queue_t *q)
{
fo_log_message_t data;
while(fo_dequeue(q, &data) > 0) {
shm_free(data.message);
if(data.prefix != NULL) {
if(data.prefix->s != NULL) {
shm_free(data.prefix->s);
}
shm_free(data.prefix);
}

if(data.message != NULL) {
if(data.message->s != NULL) {
shm_free(data.message->s);
}
shm_free(data.message);
}
}
shm_free(q);
}
Expand Down

0 comments on commit 8af509a

Please sign in to comment.