An action for the recovery of real property against a person in possession or in receipt of the rents and profits thereof cannot be prejudiced by an alienation made by that person either before or after the commencement of the action; but in such case, if the defendant has no property sufficient to satisfy the damages recovered for the withholding of possession, such damages may be collected by action against the purchaser.