The Prophet ﷺ said, "When one of you grows drowsy during prayer, let him sleep until the drowsiness leaves him, for when one of you prays while drowsy, he may intend to seek forgiveness yet end up cursing himself."
حدثنا القعنبي عن مالك عن هشام بن عروة عن أبيه
أن النبي ﷺ قال إذا نعس أحدكم في الصلاة فليرقد حتى يذهب عنه النوم فإن أحدكم إذا صلى وهو ناعس لعله يذهب يستغفر فيسب نفسه
Bukhari transmitted it, Wudu, chapter on wudu after sleep, no. 212, and Muslim, Prayer etc., no. 786, from the hadith of Malik through this route, and it is in Muwatta, Travelers, chapter on the command to one who dozes off during his prayer... (Yahya): 1/118.