Suhayl bin Abi Salih (may Allah have mercy on him) mentioned the like of this, but with some additional words: Sayyiduna Abu Hurayrah (may Allah be pleased with him) said: That I provide a whip (for use) in the path of Allah is dearer to me than that I free a child born of fornication.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الأيمان / 19988