mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Fix infinite loop in LegacyTimePeriod::FindNthWeekday().
This commit is contained in:
parent
5aeafb9f03
commit
36a45059f9
@ -54,7 +54,17 @@ bool LegacyTimePeriod::IsInTimeRange(tm *begin, tm *end, int stride, tm *referen
|
|||||||
|
|
||||||
void LegacyTimePeriod::FindNthWeekday(int wday, int n, tm *reference)
|
void LegacyTimePeriod::FindNthWeekday(int wday, int n, tm *reference)
|
||||||
{
|
{
|
||||||
int seen = 0;
|
int dir, seen = 0;
|
||||||
|
|
||||||
|
if (n > 0) {
|
||||||
|
dir = 1;
|
||||||
|
} else {
|
||||||
|
n *= -1;
|
||||||
|
dir = -1;
|
||||||
|
|
||||||
|
/* Negative days are relative to the next month. */
|
||||||
|
reference->tm_mon++;
|
||||||
|
}
|
||||||
|
|
||||||
ASSERT(n > 0);
|
ASSERT(n > 0);
|
||||||
|
|
||||||
@ -70,7 +80,7 @@ void LegacyTimePeriod::FindNthWeekday(int wday, int n, tm *reference)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reference->tm_mday++;
|
reference->tm_mday += dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user