]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Fix timer/clock_getres crash on NULL res parameter
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 15 Jan 2022 14:37:03 +0000 (15:37 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 15 Jan 2022 14:37:03 +0000 (15:37 +0100)
POSIX allows res to be NULL.

sysdeps/posix/clock_getres.c

index 252fc9b4edf113c57a07ee79636ef70bea29acc2..b6c3a10791591ea92a5ff47eb5e19151e5bcb525 100644 (file)
@@ -34,8 +34,11 @@ realtime_getres (struct timespec *res)
       /* This implementation assumes that the realtime clock has a
         resolution higher than 1 second.  This is the case for any
         reasonable implementation.  */
-      res->tv_sec = 0;
-      res->tv_nsec = 1000000000 / clk_tck;
+      if (res)
+       {
+         res->tv_sec = 0;
+         res->tv_nsec = 1000000000 / clk_tck;
+       }
       return 0;
     }