It needs to be mentioned that, in Islamic Law, blood from the womb only takes the ruling of postnatal blood if a child is delivered, alive or stillborn, that shows some human features. If a pregnancy ends in miscarriage before that time and only a lump of flesh appears, then the associated blood will not take the ruling of postnatal bleeding. Usually, this is the case when a miscarriage occurs during the first eighty or ninety days of pregnancy.
Turning to your question, there is indeed a maximum period of time that a woman abstains from prayer and fasting, even if the flow of blood after childbirth persists for longer than that.
Further bleeding will be considered to be due to an injury or illness, and not be considered postnatal bleeding.
Scholars have suggested numerous different timeframes for the maximum duration of postnatal bleeding. Some suggestions have been fourteen days, fifty days, seventy days, and even thirty if a boy child is delivered but forty if it is a girl! The official position of the Shā'fi`ī school of law is that the maximum duration of postnatal bleeding is sixty days.
However, there are only two opinions that base their arguments on actual textual evidence, and these are the only ones we shall discuss.
The first of these two opinions is that the maximum duration of postnatal bleeding is forty days. The second is that it is the same as the time for menstruation.
The claim that the maximum duration for postnatal bleeding is forty days is the opinion of the vast majority of scholars. It is the ruling adopted by three of the four schools of law: the Hanafī, Mālikī, and Hanbalī schools. This view has also been narrated as an alternative opinion of al-Shāfi`ī.
Scholars who hold this view base their argument on the hadīth of Umm Salamah which we are discussing in this article, as well as the great number of supporting narrations which strengthen that hadīth.
They also cite the undoubtedly authentic narration from Ibn `Abbās that he said: "Women in their postnatal bleeding wait for forty days." This is the opinion of that Companion. We do not know of any Companion to have expressed another opinion.
Ibn `Abd al-Barr asserts:
There is no other opinion about the maximum duration of postnatal bleeding that can be followed – either with evidence or blindly – other than the view of those who say that it is forty days. This is what the Prophet's Companions said, without exception. All the other opinions came from those who were not Companions. It is not right to adopt such opinions in contradiction with what the Companions asserted. This is because the unanimous consensus (ijmā`) of the Companions is solid evidence for later generations. How can anyone neglect what they say without even bringing a scrap of evidence from the Sunnah? [al-Istidhkār (1/400)]
Al-Tahāwī says: "None of the Companions ever said that it was sixty days. This was said by people later on." [Mukhtasar Ikhtilāf al-`Ulamā'
This period of time has been affirmed by medical specialists at the Third Conference for Islamic Medical Law which was convened in Kuwait in 1987.
The second opinion whose proponents cite hadīth evidence is that of Ibn Hazm. He argued that the maximum duration for postnatal bleeding is the same as that for menstruation.
He cited as evidence the various hadīth which discuss the duration of menstruation, like the one narrated by Himnah: "…so she menstruates for six or seven days…" [Sunan Abī Dāwūd (287), Sunan al-Tirmidhī (128) and Sunan Ibn Mājah (627)]
However, Ibn Hazm was a later scholar and he was the first person known to express this opinion. No one else ever compared the duration of postnatal bleeding to that of menstruation. If this deduction were a valid one, then it should not have gone unnoticed by all the scholars of Islam before his time.
Therefore, the correct opinion is that the maximum duration for postnatal bleeding is forty days
And Allah knows best.