Fix apparently exploitable race condition.