This won't happen. The combinations of codes far exceeds the population of the planet.
If it could happen, then I suppose that there could be a few options:
1.) find a way of increasing combinations of codes
2.) simply let overlapping codes fail
3.) don't interlink friend safaris with future games, so codes can be used in new games without being any trouble when connecting those two games (assuming same gen)