Petitor is quite correct, though the rule he gives about purpose clauses and result clauses may be extended further: as a general rule of thumb, any subordinate clause which represents the words, thoughts, perceptions, intentions, reasoning, or understanding of the subject of the independent clause will regularly use an indirect reflexive to refer back to that subject.
This includes not just purpose clauses, but jussive noun clauses (e.g. imperavit servis ut aquam ad se adferrent "he ordered his slaves to bring him water"), indirect discourse (accusative + infinitive), indirect questions, causal clauses with a subjunctive verb (to show that the reasoning is the subject's), clauses introduced by dum or antequam with a subjunctive verb (to indicate the subject's purpose or expectation), etc., etc.
Ex mala malo
bono malo uesci
quam ex bona malo
malo malo malo.