Welp, if they're the kinda guy/girl that likes undermining our relationship, I'll talk to her, and be like "hey, this person obviously is trying to undermine our relationship, you need to regulate that shit" Where as, if it's a semi decent guy/gal I try making friends with them, 'cause a lot of girls know guys get insecure about that, and showing that you're willing to build bridges with the guy/gal she was with before makes you look mature, and making that person like you helps to cut down on the aforementioned undermining.
TL;DR, Talk to you girl/guy, it'll solve 99.9% of all your relationship problems.