Commit 3b681a1b authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/tables/pat.c: Error handling in GenPAT()

Return NULL on failure of building an entire PAT.
parent 4ce2b8c3
...@@ -388,6 +388,12 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi, ...@@ -388,6 +388,12 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi,
dvbpsi_pat_program_t* p_program = p_pat->p_first_program; dvbpsi_pat_program_t* p_program = p_pat->p_first_program;
int i_count = 0; int i_count = 0;
if (p_current == NULL)
{
dvbpsi_error(p_dvbpsi, "PAT encoder", "failed to allocate new PSI section");
return NULL;
}
/* A PAT section can carry up to 253 programs */ /* A PAT section can carry up to 253 programs */
if((i_max_pps <= 0) || (i_max_pps > 253)) if((i_max_pps <= 0) || (i_max_pps > 253))
i_max_pps = 253; i_max_pps = 253;
...@@ -411,6 +417,11 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi, ...@@ -411,6 +417,11 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi,
{ {
p_prev = p_current; p_prev = p_current;
p_current = dvbpsi_NewPSISection(1024); p_current = dvbpsi_NewPSISection(1024);
if (p_current == NULL)
{
dvbpsi_error(p_dvbpsi, "PAT encoder", "failed to allocate new PSI section");
goto error;
}
p_prev->p_next = p_current; p_prev->p_next = p_current;
i_count = 1; i_count = 1;
...@@ -449,4 +460,10 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi, ...@@ -449,4 +460,10 @@ dvbpsi_psi_section_t* dvbpsi_GenPATSections(dvbpsi_t *p_dvbpsi,
} }
return p_result; return p_result;
error:
/* Cleanup on error */
p_prev = p_result;
dvbpsi_DeletePSISections(p_prev);
return NULL;
} }
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