The Messenger of Allah ﷺ said: When any of you breaks wind during the prayer, he should turn away and perform ablution and repeat the prayer. (Using translation from Abū Dāʾūd 205)
قَالَ رَسُولُ اللَّهِ ﷺ «إِذَا أَحْدَثَ أَحَدُكُمْ فِي الصَّلَاةِ فَلْيَنْصَرِفْ وَلْيَتَوَضَّأْ ثُمَّ يُصَلِّي»