Skip to content

Commit

Permalink
parser: fix two leaks
Browse files Browse the repository at this point in the history
In the event flb_strdup fails we need to bail and cleanup.

Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski authored and edsiper committed Dec 23, 2022
1 parent 68685c0 commit 9444fdc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/flb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,17 @@ struct flb_parser *flb_parser_create(const char *name, const char *format,

if (time_fmt) {
p->time_fmt_full = flb_strdup(time_fmt);
if (!p->time_fmt_full) {
flb_error("[parser:%s] could not duplicate time fmt full", name);
flb_interim_parser_destroy(p);
return NULL;
}
p->time_fmt = flb_strdup(time_fmt);
if (!p->time_fmt) {
flb_error("[parser:%s] could not duplicate time fmt", name);
flb_interim_parser_destroy(p);
return NULL;
}

/* Check if the format is considering the year */
if (strstr(p->time_fmt, "%Y") || strstr(p->time_fmt, "%y")) {
Expand Down

0 comments on commit 9444fdc

Please sign in to comment.