<!DOCTYPE html>
<html data-lt-installed="true">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body style="padding-bottom: 1px;">
    <p>Hi, Evgeniy!<br>
    </p>
    <p>Thanks for the patch! LGTM</p>
    <p>Sergey</p>
    <div class="moz-cite-prefix">On 6/29/26 20:21, Evgeniy Temirgaleev
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:31cfd9c3c72af4708b03b0ea98ca8a4e913b4599.1782588899.git.e.temirgaleev@tarantool.org">
      <pre wrap="" class="moz-quote-pre">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)
</pre>
    </blockquote>
  </body>
  <lt-container></lt-container>
</html>