Language:
كتاب العمل فى الصلاة
21  
Actions while Praying
(18)
Chapter: Thinking of something during As-Salat (the prayer)
(18)
باب تَفَكُّرِ الرَّجُلِ الشَّىْءَ فِي الصَّلاَةِ
Sahih al-Bukhari 1221

Narrated `Uqba bin Al-Harith:

I offered the `Asr prayer with the Prophet (ﷺ) and after finishing the prayer with Taslim he got up quickly and went to some of his wives and then came out. He noticed the signs of astonishment on the faces of the people caused by his speed. He then said, "I remembered while I was in my prayer that a piece of gold was Lying in my house and I disliked that it should remain with us throughout the night, and so I have ordered it to be distributed."

حَدَّثَنَا إِسْحَاقُ بْنُ مَنْصُورٍ، حَدَّثَنَا رَوْحٌ، حَدَّثَنَا عُمَرُ ـ هُوَ ابْنُ سَعِيدٍ ـ قَالَ أَخْبَرَنِي ابْنُ أَبِي مُلَيْكَةَ، عَنْ عُقْبَةَ بْنِ الْحَارِثِ ـ رضى الله عنه ـ قَالَ صَلَّيْتُ مَعَ النَّبِيِّ صلى الله عليه وسلم الْعَصْرَ، فَلَمَّا سَلَّمَ قَامَ سَرِيعًا دَخَلَ عَلَى بَعْضِ نِسَائِهِ، ثُمَّ خَرَجَ وَرَأَى مَا فِي وُجُوهِ الْقَوْمِ مِنْ تَعَجُّبِهِمْ لِسُرْعَتِهِ فَقَالَ ‏ "‏ ذَكَرْتُ وَأَنَا فِي الصَّلاَةِ تِبْرًا عِنْدَنَا، فَكَرِهْتُ أَنْ يُمْسِيَ أَوْ يَبِيتَ عِنْدَنَا فَأَمَرْتُ بِقِسْمَتِهِ ‏"‏‏.‏
Reference : Sahih al-Bukhari 1221
In-book reference : Book 21, Hadith 25
USC-MSA web (English) reference : Vol. 2, Book 22, Hadith 312
  (deprecated numbering scheme)