Shemiras Halashon Halachos

Hilchos Lashon Hara chapter 10, section 5

If one sees someone speaking lashon hara about someone that is also considered perpetration of harm and all the laws of disparaging the perpetrator mentioned above apply. This only applies if the victim knows he was spoken of. If not, one may not say the matter to anyone as the news will spread, the victim will hear of the matter, and this will count as rechilus as explained later in the laws of rechilus. Certainly, one may not reveal the matter to the victim even if one's intent is for benefit as it is certainly rechilus. This applies even if the lowliest person mocked an important person who is one's father or Torah teacher.

Hilchos Lashon Hara chapter 10, section 6

Sometimes one may relate the matter to others even if the victim does not yet know that someone spoke about him. This applies when one sees there will be some benefit, so long as all the above conditions are fulfilled -- see Be'er Mayim Chayim. For example, if one sees that the nature of the person who spoke lashon hara is such that just as he disparaged the victim to me, so he will go and disparage him before others. We already wrote that one must first rebuke him so this only applies if one rebuked him and it did not help. We know that almost everyone unfortunately believes lashon hara so that once the perpetrator speaks to other people it will be very difficult to persuade them the story was false because first impressions are the most powerful. Therefore, one may go to his potential listeners and warn them that the perpetrator is likely to come and speak falsely about the victim so that later they will not believe him. On the contrary, they will rebuke him and when he sees his deeds are causing him embarrassment he will stop his unworthy behaviour. All this is certainly permitted because it is beneficial to the victim and to the perpetrator and one also fulfils the mitzvah of giving rebuke.