The code did a pointer-sized heap allocation instead of the actual size of a semaphore struct sem_t. This could result in heap memory corruption when handling the semaphore. Found by llvm scan-build.