First of all, try to stay away from such people.
Secondly, report your work to the leader before him and communicate what you are doing to the leader.
Third, don’t talk casually in front of him, especially don’t talk about others,
Fourth, remind him at the appropriate time not to always think that he is doing everything right,
Fifth, if you can't change others, change yourself. Don't be like villains!