WIP: Fix segfault and logic error in remove_duplicate_orports()
This function tried to modify an array in place, but did it in a pretty confusing and complicated way. I've revised it to follow a much more straightforward approach.
Fixes bug #40065 (closed).
Bug not in any released Tor.
Github CI at https://github.com/torproject/tor/pull/2027