A bigger problem is that your function is bugous.

I mean, if your binary search just happens to land on the first of two occurrences and there are exactly two occurrences, well, OK, but. a few...