Skip to content

Commit 29c6282

Browse files
committed
Fluentbit crashes when channel does not exists or it is ignored
1 parent f4108db commit 29c6282

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

plugins/in_winevtlog/in_winevtlog.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ static int in_winevtlog_collect(struct flb_input_instance *ins,
390390
struct mk_list *head;
391391
struct winevtlog_channel *ch;
392392

393+
/* If there are no active channels (e.g., all missing and ignored),
394+
* there is nothing to collect. Guard against NULL to avoid dereferencing.
395+
*/
396+
if (ctx == NULL || ctx->active_channel == NULL) {
397+
return 0;
398+
}
399+
393400
mk_list_foreach(head, ctx->active_channel) {
394401
ch = mk_list_entry(head, struct winevtlog_channel, _head);
395402
in_winevtlog_read_channel(ins, ctx, ch);
@@ -417,7 +424,9 @@ static int in_winevtlog_exit(void *data, struct flb_config *config)
417424
return 0;
418425
}
419426

420-
winevtlog_close_all(ctx->active_channel);
427+
if (ctx->active_channel) {
428+
winevtlog_close_all(ctx->active_channel);
429+
}
421430

422431
if (ctx->db) {
423432
flb_sqldb_close(ctx->db);

0 commit comments

Comments
 (0)