lib: Fixed potential kqueue timespec storage bug.
authorFredrik Tolf <fredrik@rpi2.dolda2000.com>
Sat, 11 Mar 2017 05:08:03 +0000 (05:08 +0000)
committerFredrik Tolf <fredrik@rpi2.dolda2000.com>
Sat, 11 Mar 2017 05:08:03 +0000 (05:08 +0000)
lib/mtio-kqueue.c

index b4e7427..7d086e2 100644 (file)
@@ -287,12 +287,13 @@ int ioloop(void)
     }
     while(blockers != NULL) {
        now = time(NULL);
+       toval = &(struct timespec){};
        if(timeheap.d == 0)
            toval  = NULL;
        else if(timeheap.b[0]->to > now)
-           toval = &(struct timespec){.tv_sec = timeheap.b[0]->to - now};
+           *toval = (struct timespec){.tv_sec = timeheap.b[0]->to - now};
        else
-           toval = &(struct timespec){.tv_sec = 1};
+           *toval = (struct timespec){.tv_sec = 1};
        if(exitstatus)
            break;
        nev = kevent(qfd, NULL, 0, evs, sizeof(evs) / sizeof(*evs), toval);