I have to say I would need to see very clear evidence to believe there is a bug here. A lot of people rely on this code working, and they do not encounter any problems.
The best way to check is, find one quiz attempt where you think the same question has been selected twice. Review that quiz attempt as teacher/admin, and by every question there will be an 'Edit question'. Check what URL that link goes to, and it will include &id=12345 at the end, where 12345 it the id Moodle users to identify the question.
If there are two questions in the quiz with the same id, then there is really a bug, and so please tell us as many deatails as possible about how that quiz is set up. (Including exactly which Moodle version you are using.)
If the ids are different (and the questions merely look the same) then you made a mistake in setting up your quiz.