From: Bill Lash Date: Fri, 28 Jun 2019 05:29:04 +0000 (-0500) Subject: Check for NULL dispatch semaphore ptr on MAC X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=14d7908c932f3db5ba55965ece40126f584f702d;p=liskon_frotz.git Check for NULL dispatch semaphore ptr on MAC --- diff --git a/src/curses/ux_sema.h b/src/curses/ux_sema.h index 7a01cd4..baf3656 100644 --- a/src/curses/ux_sema.h +++ b/src/curses/ux_sema.h @@ -49,17 +49,21 @@ static inline void ux_sem_init(ux_sem_t *sem, int pshared, unsigned int value) static inline void ux_sem_post(ux_sem_t *sem) { - dispatch_semaphore_signal(sem->dsem); + if (sem->dsem != NULL) + dispatch_semaphore_signal(sem->dsem); } static inline void ux_sem_wait(ux_sem_t *sem) { - dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_FOREVER); + if (sem->dsem != NULL) + dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_FOREVER); } static inline int ux_sem_trywait(ux_sem_t *sem) { - return (int) dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_NOW); + if (sem->dsem != NULL) + return (int) dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_NOW); + return -1; } #else #include