It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) said: "Whoever imagines during his prayer that he has broken his ablution should by no means leave (the prayer) until he hears a sound (of passing wind) or finds a smell."
A narration like it has already come in the entry of Thawr bin Zayd from Ikrimah (may Allah have mercy on them both).
Related hadith on this topic