The Messenger of Allah ﷺ said, "When one of you grows drowsy while praying, let him lie down to sleep until the drowsiness leaves him, for when one of you prays while drowsy, he does not realize that perhaps he intends to seek forgiveness but ends up cursing himself instead."
أن رسول الله ﷺ قال: إذا نعس أحدكم وهو يصلي فليرقد حتى يذهب عنه النوم، فإن أحدكم إذا صلى وهو ناعس لا يدري لعله يذهب يستغفر فيسب نفسه.
Malik narrated it in "The Night Prayer" (3) from Hisham bin Urwa, from his father, from Ayesha, and she mentioned the same account. Bukhari narrated it in "Wudu" (212) from Abdullah bin Yusuf, and Muslim narrated it in "The Prayer of the Traveler" (786), through various chains, both of them from Malik bin Anas with the same wording.