reference: check for unset leap_when in is_leap_close()

Check that the leap_when variable is set before testing a timestamp for
being close to a leap second. This allows the first measurement to be
accepted if starting at the Unix epoch (e.g. in a test).
This commit is contained in:
Miroslav Lichvar 2021-12-01 09:14:34 +01:00
parent 6a79771898
commit 89a5e21e4d

View file

@ -1333,7 +1333,8 @@ REF_DisableLocal(void)
static int
is_leap_close(time_t t)
{
return t >= leap_when - LEAP_SECOND_CLOSE && t < leap_when + LEAP_SECOND_CLOSE;
return leap_when != 0 &&
t >= leap_when - LEAP_SECOND_CLOSE && t < leap_when + LEAP_SECOND_CLOSE;
}
/* ================================================== */