"Dobby cannot let Harry Potter lose his Wheezy!" --Dobby (GF26)
Dobby wakes Harry up ten minutes before the second task, tells him that he will have to rescue Ron, and gives him Gillyweed (GF26).
Harry had fallen asleep in the library, where he was doing research trying to solve the egg’s riddle. Luckily, the Invisibility Cloak slipped off his head while he was sleeping. Upon waking, Harry initially thinks he won’t be able to compete because he had not solved the riddle. At first, Harry is not sure that Dobby knows what he is talking about. Once Dobby explains that he learned about the second task by overhearing a discussion in the staffroom, however, Harry takes the Gillyweed from Dobby and hurries to the lake (GF26).
Dobby wakes Harry up at 9:20 in the morning, just ten minutes before the second task's 9:30 start time (GF26).
In the film version of GF, Neville gives Harry the gillyweed.