There are two group of objects: A and B. Each A has one or more Bs. The old code was written with the assumptions that B objects can be reused across As, by just moving pointers. New code broke this assumption by tieing it to the parent A and introducing a shared field with A (again, shared by pointer). So, the bug was in old code, which was correct under old assumptions, but incorrect under new ones.
I am not sure what's the right way to avoid this class of bugs as a whole. I'd just be extremely careful with reusing/sharing objects by pointers, and add a comment in class definition for every field where it's a case.