Fiqh-us-Sunnah Volume 4, Funerals and Dhikr, Fiqh 4.060.

Section : Not Attending a Funeral due to Some Forbidden Acts.

The author of Al-Mughni said: “If one sees or hears something that is forbidden while attending a funeral, and one is capable of countering and rectifying it, one should do so. If not, then one may do one of two things: voice his disapproval of it, and continue with the funeral which will free one from any responsibility of any such disapproved acts, without abandoning the good for the bad. The second course open to a person in such a case is to leave the funeral procession, especially when one is able to leave it, so that one’s continued participation will not lead one to hear or see a forbidden thing.”