From: Miroslav Lichvar Date: Wed, 1 Dec 2021 08:14:34 +0000 (+0100) Subject: reference: check for unset leap_when in is_leap_close() X-Git-Tag: 4.2-pre1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89a5e21e4d9765ba1339c20af8fbb48653506800;p=thirdparty%2Fchrony.git 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). --- diff --git a/reference.c b/reference.c index bf309916..90323230 100644 --- a/reference.c +++ b/reference.c @@ -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; } /* ================================================== */