This small patch aims to fix T86561.
Problem:
Selecting two objects with linked object data in the reverse order to which they were linked while in Object Mode and then attempting to enter Edit Mode causes a crash.
Where the problem lies:
The LISTBASE_FOREACH loop modified in the diff did not take into account the case where multiple objects are different but have the same object data pointer. In the case where one of these objects is the obact pointer there is a problem. If this obact object comes after the others in the loop, it's id->tag is already updated previously, meaning len is not updated correctly causing r_active_index to be set incorrectly also. This causes a segmentation fault further down the line.
Fix:
Therefore, my proposed fix is a simple if statement which gurantees that if the object whose object data tag is being updated is not the obact object, then it is also not one of the other objects who share the same object data as the obact object.
Note:
While the original ticket only showed the case where two objects have linked object data, the crash does infact occur for any number of linked objects and this fix works regardless.