public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [hurd, commited] hurd: Fix timer/clock_getres crash on NULL res parameter
@ 2022-01-15 14:37 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2022-01-15 14:37 UTC (permalink / raw)
  To: libc-alpha; +Cc: Samuel Thibault, commit-hurd

POSIX allows res to be NULL.
---
 sysdeps/posix/clock_getres.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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;
     }
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-15 14:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-15 14:37 [hurd, commited] hurd: Fix timer/clock_getres crash on NULL res parameter Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).