Fix sem is NULL bug