They hadn't meant to eavesdrop, they really hadn't.
It was just that Neville had lost Trevor again, and, after an extensive search of Gryffindor common room, they had come to the conclusion that the toad had made a break for it, and was probably adventuring the depths of the Hogwarts corridors.
Unfortunately, this realization had come well after curfew, and there was exactly no way Filch would let them off, if he caught them wandering the halls after hours. (By this point, Neville was kind of sniffling, though he'd later deny it, and generally kind of freaking out about Trevor getting lost or stepped on or eaten by Mrs. Norris.)
So, Harry donned his Invisibility Cloak, and prepared to set out in search of the wayward pet. And, of course, Ron and Hermione weren't about to let him go alone. With all three of them squeezed under the cloak, and Neville waving them a tearful goodbye from the portrait frame, the Golden Trio set out to go toad hunting.
They had found Trevor lurking in, what Hermione had identified as, the Teacher's Hallway. Ron gathered up the toad, and the Golden Trio was prepared to head back to the common room, when voices from a nearby room drew their attention.
Which is where the 'eavesdropping' bit comes in.
"Mister Reilly, I don't believe I will renew the spells, until you agree to go see Poppy." The voice was undeniably McGonagall. And she was talking to Professor Reilly about spell casting and the Hospital Wing.
"I'm fine." Professor Reilly's voice was brusque and insisting. The argument had the tone of being an old one.
"You are most certainly not!" McGonagall snapped. "You're getting worse, if anything. Now, I don't know what you have against the Dreamless Sleep-" Reilly cut her off. "Professor, have you ever imagined what I must have done to wake me up with screaming nightmares?" His voice was cold now, and low. "Maybe this is nothing more than what I deserve."
He didn't elaborate on anything, and McGonagall didn't ask him to.
Harry, Ron and Hermione practically ran all the way back to Gryffindor Tower.
