From d7bee91a2ed0edb89e47d897f1d5ae6a7d9f8fb6 Mon Sep 17 00:00:00 2001
From: Rob Swindell <rob@synchro.net>
Date: Mon, 29 Nov 2021 18:02:19 -0800
Subject: [PATCH] Fix sem_wait() call in vdd_read()

Introduced in Revision 1.16 (CVS)
Wed May 10 08:52:11 2006 UTC (15 years, 6 months ago) by rswindell

This was supposed to wait (block) until there was a new received
byte (the ringbuf semaphore was signaled), but we were passing the sem_t
value rather than the pointer to the sem_t. Since sem_t (on Windows)
is a HANDLE (which is a void*), there was no compiler warning or
error. Type-safety in C sucks.
So, this just never worked (I'm assuming the call would just fail).

I discovered this bug while working on NTVDMx64 support and in that
case, this call would block/wait forever. Simple one character fix.
---
 src/sbbs3/sbbsexec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sbbs3/sbbsexec.c b/src/sbbs3/sbbsexec.c
index 2184283136..7579d2f935 100644
--- a/src/sbbs3/sbbsexec.c
+++ b/src/sbbs3/sbbsexec.c
@@ -255,7 +255,7 @@ void _cdecl input_thread(void* arg)
 
 unsigned vdd_read(BYTE* p, unsigned count)
 {
-	sem_wait(rdbuf.sem);
+	sem_wait(&rdbuf.sem);
 	count=RingBufRead(&rdbuf,p,count);
 	if(count==0)
 		lprintf(LOG_ERR,"!VDD_READ: RingBufRead read 0");
-- 
GitLab