Hi, Evgeniy!
Thanks for the patch! LGTM
Sergey
From: Mike Pall <mike>
Thanks to Temir Galeev. #1470
(cherry picked from commit 295d45fb26de56498782c94594f31b97aef744ef)
This patch prevents os.time() to return nil, when machine time is -1
and some error occurs before 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
---
src/lib_os.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib_os.c b/src/lib_os.c
index f6841357..d4054eae 100644
--- a/src/lib_os.c
+++ b/src/lib_os.c
@@ -229,6 +229,7 @@ LJLIB_CF(os_date)
LJLIB_CF(os_time)
{
time_t t;
+ errno = 0;
if (lua_isnoneornil(L, 1)) { /* called without args? */
t = time(NULL); /* get current time */
} else {
@@ -242,7 +243,6 @@ LJLIB_CF(os_time)
ts.tm_mon = getfield(L, "month", -1) - 1;
ts.tm_year = getfield(L, "year", -1) - 1900;
ts.tm_isdst = getboolfield(L, "isdst");
- errno = 0;
t = mktime(&ts);
}
if (t == (time_t)(-1) && errno != 0)