Scott's correct that if there's something in her lease permitting her to terminate it for the purchase of a property, then, so long as she abides by the terms of the lease, she'd be OK.
But there's no magic wand that taps new home buyers on the shoulder and says: "I relieve you of your obligation to pay your rent as you agreed to."
She can help prevent being liable by trying to find a new tenant on her own before she vacates, that is acceptable to the landlord.
Also, the landlord can not just sit back for 5 months and expect her to pay the rent on a vacant dwelling. By law, he has to make an attempt to re-rent the dwelling for the same cost to others in order to mitigate the damages (loss of income) he has incurred by her early departure. She would be liable for advertising costs and those months it took to find a new tenant.
She will definitely lose her security deposit.