in clock_getres, check for null pointer before storing result
authorRich Felker <dalias@aerifal.cx>
Thu, 8 Aug 2019 01:35:28 +0000 (21:35 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 8 Aug 2019 01:35:28 +0000 (21:35 -0400)
POSIX allows a null pointer, in which case the function only checks
the validity of the clock id argument.

src/time/clock_getres.c

index f0f41cf9ec0aa04c0044ac8c5e317d95f0895421..81c6703761d4484f4001d10a22123a9a5b859ce6 100644 (file)
@@ -8,7 +8,7 @@ int clock_getres(clockid_t clk, struct timespec *ts)
        if (SYS_clock_getres != SYS_clock_getres_time64) {
                long ts32[2];
                int r = __syscall(SYS_clock_getres, clk, ts32);
-               if (!r) {
+               if (!r && ts) {
                        ts->tv_sec = ts32[0];
                        ts->tv_nsec = ts32[1];
                }