Skip to content

Commit 99e347f

Browse files
cosmo0920edsiper
authored andcommitted
in_winevtlog: Add NULL checks
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 228c6e0 commit 99e347f

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

plugins/in_winevtlog/winevtlog.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,13 @@ static int query_for_channel(const char *query, const char *channel,
276276
*channel_query = NULL;
277277

278278
if (!query_is_structured_xml(query)) {
279-
*channel_query = flb_sds_create(query);
280-
return *channel_query == NULL ? -1 : 0;
279+
if (query != NULL) {
280+
*channel_query = flb_sds_create(query);
281+
if (*channel_query == NULL) {
282+
return -1;
283+
}
284+
}
285+
return 0;
281286
}
282287

283288
output = flb_sds_create("<QueryList>");
@@ -1178,7 +1183,11 @@ int winevtlog_try_reconnect(struct winevtlog_channel *ch, struct winevtlog_confi
11781183
if (!wide_channel) {
11791184
return -1;
11801185
}
1181-
MultiByteToWideChar(CP_UTF8, 0, ch->name, -1, wide_channel, len);
1186+
if (MultiByteToWideChar(CP_UTF8, 0, ch->name, -1,
1187+
wide_channel, len) == 0) {
1188+
flb_free(wide_channel);
1189+
return -1;
1190+
}
11821191
}
11831192

11841193
if (ch->query) {

0 commit comments

Comments
 (0)