Shemiras Halashon Halachos

Hilchos Lashon Hara chapter 10, section 3

This only applies if the person was better than the wrongdoer, but if he is a sinner like him and does the same sins, he may not publicize him. For such a person's intent is not for benefit or due to fear of G-d, but to rejoice at his downfall and embarrass him. It already says regarding this, I will punish the house of Yehu for the blood of Yizrael (Hoshea 1:4). Even though Yehu did a mitzvah by cutting off the house of Achav in Yizrael, for so he was commanded by a prophet, and he received in return kingship for four generations as it says, Because you did My heart's desire to the house of Achav, sons of the fourth generation will sit of you on the throne of Yisrael (II Melachim 10:30), nonetheless, he was punished because he too had many sins.

Hilchos Lashon Hara chapter 10, section 4

We wrote earlier that the fifth condition is that a person's intent should be for a beneficial purpose. This certainly applies if the people one is speaking to help a robbed, oppressed, injured, or shamed person. Even if the benefit cannot be achieved through one's telling the story, but one intends to keep people from evil when they hear people denigrating sinners, and the offender himself may repent and emend his deeds when he hears people disparaging him, this too counts as a benefit. For the speaker has no intent to gain enjoyment from the person's flaws and is jealous for the truth. But if he estimates that there will certainly be no benefit as in a case where the listeners are wicked people who do the same evils and consider them as nothing, one should not relate what happened. Besides there being no benefit, great harm may result if they go and repeat to the perpetrator that one spoke of him, transgressing, You shall not go as a talebearer (Vayikra 19:16). Also, great controversy often results from this. If relating the story can lead to people reporting a Jew to the authorities it is certainly forbidden even if all the conditions are fulfilled. It makes no difference regarding all this whether the victim of the perpetrator asked one for help or not and whether the victim was a relative. (Many people mistakenly take action against a perpetrator on behalf of a relative even if the facts are not clear, thinking they are fulfilling the mitzvah, Do not hide from your flesh (Yeshayahu 58:7). This is a mistake).