This sounds like a misremembered version of Cymbeline, one of Shakespeare's last plays. This play contains a scene where someone hides in a woman's room. Here's a quote from the Wikipedia article (emphasis added):
Posthumus must now live in Italy, where he meets Iachimo (or Giacomo), who challenges the prideful Posthumus to a bet that he, Iachimo, can seduce Imogen, who Posthumus has praised for her chastity, and then bring Posthumus proof of Imogen's adultery. If Iachimo wins, he will get Posthumus's token ring. If Posthumus wins, not only must Iachimo pay him but also fight Posthumus in a duel with swords. Iachimo heads to Britain where he aggressively attempts to seduce the faithful Imogen, who sends him packing. Iachimo then hides in a chest in Imogen's bedchamber and, when the princess falls asleep, emerges to steal from her Posthumus's bracelet. He also takes note of the room and Imogen's partly naked body to be able to present false evidence to Posthumus that he has seduced his bride.
At the end of the play, Imogen's father, King Cymbeline, forgives Iachimo, and Imogen can marry Posthumus. So I am not sure where the part about the woman saving the man comes from.