Skip to content

Commit 1eeef25

Browse files
Mike PallBuristan
authored andcommitted
Make check in os.time() consistent.
Thanks to Temir Galeev. (cherry picked from commit 295d45f) This patch prevents os.time() from returning nil, when machine time is -1 and some error occurs before the os.time() call. In fact, this is a theoretical case, so no tests were added. Temir Galeev: * added the description for the patch Part of tarantool/tarantool#12480 Reviewed-by: Sergey Kaplun <skaplun@tarantool.org> Reviewed-by: Sergey Bronnikov <sergeyb@tarantool.org> Signed-off-by: Sergey Kaplun <skaplun@tarantool.org> (cherry picked from commit 2f7f0ba)
1 parent 8e4f984 commit 1eeef25

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/lib_os.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ LJLIB_CF(os_date)
229229
LJLIB_CF(os_time)
230230
{
231231
time_t t;
232+
errno = 0;
232233
if (lua_isnoneornil(L, 1)) { /* called without args? */
233234
t = time(NULL); /* get current time */
234235
} else {
@@ -242,7 +243,6 @@ LJLIB_CF(os_time)
242243
ts.tm_mon = getfield(L, "month", -1) - 1;
243244
ts.tm_year = getfield(L, "year", -1) - 1900;
244245
ts.tm_isdst = getboolfield(L, "isdst");
245-
errno = 0;
246246
t = mktime(&ts);
247247
}
248248
if (t == (time_t)(-1) && errno != 0)

0 commit comments

Comments
 (0)