Bulugh al-Maram 80
Narrated Mu’awiyah (rad):
Allah’s Messenger (saW) said: “The eye (when awake) is the string of the anus (to stop air escaping), and if the two eyes sleep the string is untied”. [Reported by Ahmad and At-Tabarani who added, “Whoever sleeps should perform ablution]”
وَعَنْ مُعَاوِيَةَ ‏- رضى الله عنه ‏- قَالَ: قَالَ رَسُولُ اَللَّهِ ‏- صلى الله عليه وسلم ‏-{ الْعَيْنُ وِكَاءُ السَّهِ, فَإِذَا نَامَتْ اَلْعَيْنَانِ اِسْتَطْلَقَ اَلْوِكَاءُ }  رَوَاهُ أَحْمَدُ, وَالطَّبَرَانِيُّ وَزَادَ { وَمَنْ نَامَ فَلْيَتَوَضَّأْ }