aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2026-06-13 10:59:29 +0200
committerMike Pall <mike>2026-06-13 10:59:29 +0200
commit72d2061ae2fa9a5fd45237943f9982baf59435ec (patch)
treef9d2e5bc85309235e6825d101490633713d0f565 /src
parentc3b379bf50c8819c61daa3afd9f21d9ec5708bd5 (diff)
downloadluajit-72d2061ae2fa9a5fd45237943f9982baf59435ec.tar.gz
luajit-72d2061ae2fa9a5fd45237943f9982baf59435ec.tar.bz2
luajit-72d2061ae2fa9a5fd45237943f9982baf59435ec.zip
Fix corner case of os.time().
Thanks to Temir Galeev. #1470
Diffstat (limited to 'src')
-rw-r--r--src/lib_os.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib_os.c b/src/lib_os.c
index 60b7b82d6..4715e64cd 100644
--- a/src/lib_os.c
+++ b/src/lib_os.c
@@ -237,9 +237,10 @@ LJLIB_CF(os_time)
237 ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u); 237 ts.tm_mon = (int)((unsigned int)getfield(L, "month", -1) - 1u);
238 ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u); 238 ts.tm_year = (int)((unsigned int)getfield(L, "year", -1) - 1900u);
239 ts.tm_isdst = getboolfield(L, "isdst"); 239 ts.tm_isdst = getboolfield(L, "isdst");
240 errno = 0;
240 t = mktime(&ts); 241 t = mktime(&ts);
241 } 242 }
242 if (t == (time_t)(-1)) 243 if (t == (time_t)(-1) && errno != 0)
243 lua_pushnil(L); 244 lua_pushnil(L);
244 else 245 else
245 lua_pushnumber(L, (lua_Number)t); 246 lua_pushnumber(L, (lua_Number)t);