From 89a5e21e4d9765ba1339c20af8fbb48653506800 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 1 Dec 2021 09:14:34 +0100 Subject: [PATCH] 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). --- reference.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reference.c b/reference.c index bf30991..9032323 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; } /* ================================================== */