]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: gettimeofday: allow tv NULL pointer
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 20 Feb 2024 11:30:34 +0000 (12:30 +0100)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 20 Feb 2024 11:30:34 +0000 (12:30 +0100)
Add a missing check for the struct timeval pointer being NULL.

Reported-by: 109224573 <109224573@qq.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/release/3.5.1
winsup/cygwin/times.cc

index 96d2ad32fa79d7e764dd03d8ff0ab029bc44c85d..f3983c450dd97a89858bd8c849f0183e5b7ef899 100644 (file)
@@ -20,3 +20,6 @@ Fixes:
 - Fix the problem that VMIN and VTIME does not work at all in console.
 
 - Fix a bug that cannot handle consoles more than 32, rather than 64.
+
+- Fix gettimeofday not checking for a NULL pointer
+  Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255473.html
index 87773934bfd778c84688133c9e27d6beb4bab8a8..71a7210318fa19b3af7180fd35c5501b0788a93c 100644 (file)
@@ -172,10 +172,13 @@ gettimeofday (struct timeval *__restrict tv, void *__restrict tzvp)
   static bool tzflag;
   LONGLONG now = get_clock (CLOCK_REALTIME)->usecs ();
 
-  tv->tv_sec = now / USPERSEC;
-  tv->tv_usec = now % USPERSEC;
+  if (tv)
+    {
+      tv->tv_sec = now / USPERSEC;
+      tv->tv_usec = now % USPERSEC;
+    }
 
-  if (tz != NULL)
+  if (tz)
     {
       if (!tzflag)
        {
This page took 0.036824 seconds and 5 git commands to generate.