diff mbox series

[hurd,commited] hurd: Fix timer/clock_getres crash on NULL res parameter

Message ID 20220115143741.302243-1-samuel.thibault@ens-lyon.org
State Committed, archived
Headers show
Series [hurd,commited] hurd: Fix timer/clock_getres crash on NULL res parameter | expand

Checks

Context Check Description
dj/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent
dj/TryBot-32bit fail Patch series failed to apply

Commit Message

Samuel Thibault Jan. 15, 2022, 2:37 p.m. UTC
POSIX allows res to be NULL.
---
 sysdeps/posix/clock_getres.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
index 252fc9b4ed..b6c3a10791 100644
--- a/sysdeps/posix/clock_getres.c
+++ b/sysdeps/posix/clock_getres.c
@@ -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;
     }