If the purchaser of real property sold on execution, or his successors in interest, are evicted therefrom in consequence of the reversal of the judgment, he or they may recover the price paid, with legal interest and the costs and disbursements of the action by which he or they were evicted, from the plaintiff in the writ of execution.