Skip to content

Commit d861d45

Browse files
committed
Fix: Handle undefined direction in alerts
In alerts with the "Filter count changed" condition, the check now always falls back to checking if the count increased if the "direction" condition data is not defined. Without the fix having it undefined could cause a segmentation fault.
1 parent 41a645d commit d861d45

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/manage_sql.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14322,7 +14322,10 @@ condition_met (task_t task, report_t report, alert_t alert,
1432214322
{
1432314323
/* Same as "increased". */
1432414324
if (cmp >= count)
14325-
return 1;
14325+
{
14326+
free (filter_id);
14327+
return 1;
14328+
}
1432614329
}
1432714330
else if (((strcasecmp (direction, "changed") == 0)
1432814331
&& (abs (cmp) >= count))
@@ -14341,7 +14344,16 @@ condition_met (task_t task, report_t report, alert_t alert,
1434114344
g_debug ("direction: %s", direction);
1434214345
g_debug ("last_count: %i", last_count);
1434314346
g_debug ("second_last_count NULL");
14344-
if (((strcasecmp (direction, "changed") == 0)
14347+
if (direction == NULL)
14348+
{
14349+
/* Same as "increased". */
14350+
if (last_count > 0)
14351+
{
14352+
free (filter_id);
14353+
return 1;
14354+
}
14355+
}
14356+
else if (((strcasecmp (direction, "changed") == 0)
1434514357
|| (strcasecmp (direction, "increased") == 0))
1434614358
&& (last_count > 0))
1434714359
{

0 commit comments

Comments
 (0)