fix double-free if the number of languages is reduced to zero