Crash was observed in this function when fSemaphore was NULL, this patch copies the NULL pointer check from the commented function above into Wait()