Commit 9ae00f93 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/dvbpsi.c: fix segmentation fault in dvbpsi_decoder_psi_section_add()

When p->i_number == p_section->i_number AND p_prev == NULL, then the function
will crash with a segmentation fault. In this case the first element in the linked
list is going to be replaced. The pointer p_prev does not point to a valid sections,
since p is the first element in the list. To solve this case it needs to be treated
seperate.
parent 81a0414e
......@@ -258,11 +258,22 @@ bool dvbpsi_decoder_psi_section_add(dvbpsi_decoder_t *p_decoder, dvbpsi_psi_sect
if (p->i_number == p_section->i_number)
{
/* Replace */
p_prev->p_next = p_section;
p_section->p_next = p->p_next;
p->p_next = NULL;
dvbpsi_DeletePSISections(p);
b_overwrite = true;
if (p_prev)
{
p_prev->p_next = p_section;
p_section->p_next = p->p_next;
p->p_next = NULL;
dvbpsi_DeletePSISections(p);
b_overwrite = true;
}
else
{
p_section->p_next = p->p_next;
p->p_next = NULL;
dvbpsi_DeletePSISections(p);
p = p_section;
b_overwrite = true;
}
goto out;
}
else if (p->i_number > p_section->i_number)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment