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

src/tables: solve potential memleaks.

parent b8303d17
...@@ -194,7 +194,7 @@ void dvbpsi_DeleteDemuxSubDecoder(dvbpsi_demux_subdec_t *p_subdec) ...@@ -194,7 +194,7 @@ void dvbpsi_DeleteDemuxSubDecoder(dvbpsi_demux_subdec_t *p_subdec)
if (!p_subdec) if (!p_subdec)
return; return;
/* FIXME: find a saner way to release private decoder resources */ /* FIXME: find a saner way to release private decoder resources */
free(p_subdec->p_decoder); dvbpsi_DeleteDecoder(p_subdec->p_decoder);
free(p_subdec); free(p_subdec);
p_subdec = NULL; p_subdec = NULL;
} }
......
...@@ -158,16 +158,17 @@ void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -158,16 +158,17 @@ void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
return; return;
if (p_eit_decoder->p_building_eit) if (p_eit_decoder->p_building_eit)
free(p_eit_decoder->p_building_eit); dvbpsi_atsc_DeleteEIT(p_eit_decoder->p_building_eit);
p_eit_decoder->p_building_eit = NULL;
for (unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
{ {
if (p_eit_decoder->ap_sections[i]) if (p_eit_decoder->ap_sections[i])
{
dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]);
p_eit_decoder->ap_sections[i] = NULL;
}
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
...@@ -402,7 +403,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi, ...@@ -402,7 +403,7 @@ static void dvbpsi_atsc_GatherEITSections(dvbpsi_t * p_dvbpsi,
/* Free structures */ /* Free structures */
if (p_eit_decoder->p_building_eit) if (p_eit_decoder->p_building_eit)
{ {
free(p_eit_decoder->p_building_eit); dvbpsi_atsc_DeleteEIT(p_eit_decoder->p_building_eit);
p_eit_decoder->p_building_eit = NULL; p_eit_decoder->p_building_eit = NULL;
} }
/* Clear the section array */ /* Clear the section array */
......
...@@ -144,8 +144,9 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -144,8 +144,9 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -168,9 +169,6 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -168,9 +169,6 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
free(p_etm_version); free(p_etm_version);
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
} }
......
...@@ -163,16 +163,17 @@ void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -163,16 +163,17 @@ void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
return; return;
if (p_mgt_decoder->p_building_mgt) if (p_mgt_decoder->p_building_mgt)
free(p_mgt_decoder->p_building_mgt); dvbpsi_atsc_DeleteMGT(p_mgt_decoder->p_building_mgt);
p_mgt_decoder->p_building_mgt = NULL;
for (unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
{ {
if (p_mgt_decoder->ap_sections[i]) if (p_mgt_decoder->ap_sections[i])
{
dvbpsi_DeletePSISections(p_mgt_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_mgt_decoder->ap_sections[i]);
p_mgt_decoder->ap_sections[i] = NULL;
}
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
...@@ -436,7 +437,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi, ...@@ -436,7 +437,7 @@ static void dvbpsi_atsc_GatherMGTSections(dvbpsi_t * p_dvbpsi,
/* Free structures */ /* Free structures */
if(p_mgt_decoder->p_building_mgt) if(p_mgt_decoder->p_building_mgt)
{ {
free(p_mgt_decoder->p_building_mgt); dvbpsi_atsc_DeleteMGT(p_mgt_decoder->p_building_mgt);
p_mgt_decoder->p_building_mgt = NULL; p_mgt_decoder->p_building_mgt = NULL;
} }
/* Clear the section array */ /* Clear the section array */
......
...@@ -138,9 +138,6 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -138,9 +138,6 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
if(!p_stt_decoder) if(!p_stt_decoder)
return; return;
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
} }
......
...@@ -172,15 +172,18 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -172,15 +172,18 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_subdec->p_decoder; p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_subdec->p_decoder;
if (!p_vct_decoder) if (!p_vct_decoder)
return; return;
free(p_vct_decoder->p_building_vct); if (p_vct_decoder->p_building_vct)
dvbpsi_atsc_DeleteVCT(p_vct_decoder->p_building_vct);
p_vct_decoder->p_building_vct = NULL;
for (unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
{ {
if (p_vct_decoder->ap_sections[i]) if (p_vct_decoder->ap_sections[i])
{
dvbpsi_DeletePSISections(p_vct_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_vct_decoder->ap_sections[i]);
p_vct_decoder->ap_sections[i] = NULL;
}
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
...@@ -473,7 +476,7 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi, ...@@ -473,7 +476,7 @@ static void dvbpsi_atsc_GatherVCTSections(dvbpsi_t *p_dvbpsi,
/* Free structures */ /* Free structures */
if(p_vct_decoder->p_building_vct) if(p_vct_decoder->p_building_vct)
{ {
free(p_vct_decoder->p_building_vct); dvbpsi_atsc_DeleteVCT(p_vct_decoder->p_building_vct);
p_vct_decoder->p_building_vct = NULL; p_vct_decoder->p_building_vct = NULL;
} }
......
...@@ -62,7 +62,6 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -62,7 +62,6 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
dvbpsi_error(p_dvbpsi, "BAT decoder", dvbpsi_error(p_dvbpsi, "BAT decoder",
...@@ -128,15 +127,18 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -128,15 +127,18 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_bat_decoder_t* p_bat_decoder; dvbpsi_bat_decoder_t* p_bat_decoder;
p_bat_decoder = (dvbpsi_bat_decoder_t*)p_subdec->p_decoder; p_bat_decoder = (dvbpsi_bat_decoder_t*)p_subdec->p_decoder;
free(p_bat_decoder->p_building_bat); if (p_bat_decoder->p_building_bat)
dvbpsi_DeleteBAT(p_bat_decoder->p_building_bat);
p_bat_decoder->p_building_bat = NULL;
for (unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
{ {
if (p_bat_decoder->ap_sections[i]) if (p_bat_decoder->ap_sections[i])
{
dvbpsi_DeletePSISections(p_bat_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_bat_decoder->ap_sections[i]);
p_bat_decoder->ap_sections[i] = NULL;
}
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
...@@ -391,7 +393,7 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi, ...@@ -391,7 +393,7 @@ void dvbpsi_GatherBATSections(dvbpsi_t *p_dvbpsi,
/* Free structures */ /* Free structures */
if (p_bat_decoder->p_building_bat) if (p_bat_decoder->p_building_bat)
{ {
free(p_bat_decoder->p_building_bat); dvbpsi_DeleteBAT(p_bat_decoder->p_building_bat);
p_bat_decoder->p_building_bat = NULL; p_bat_decoder->p_building_bat = NULL;
} }
/* Clear the section array */ /* Clear the section array */
......
...@@ -91,15 +91,20 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi) ...@@ -91,15 +91,20 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi)
dvbpsi_cat_decoder_t* p_cat_decoder dvbpsi_cat_decoder_t* p_cat_decoder
= (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private; = (dvbpsi_cat_decoder_t*)p_dvbpsi->p_private;
free(p_cat_decoder->p_building_cat); if (p_cat_decoder->p_building_cat)
dvbpsi_DeleteCAT(p_cat_decoder->p_building_cat);
p_cat_decoder->p_building_cat = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
if (p_cat_decoder->ap_sections[i]) if (p_cat_decoder->ap_sections[i])
free(p_cat_decoder->ap_sections[i]); {
dvbpsi_DeletePSISections(p_cat_decoder->ap_sections[i]);
p_cat_decoder->ap_sections[i] = NULL;
}
} }
dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private); dvbpsi_DeleteDecoder(p_dvbpsi->p_private);
p_dvbpsi->p_private = NULL; p_dvbpsi->p_private = NULL;
} }
...@@ -110,6 +115,8 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi) ...@@ -110,6 +115,8 @@ void dvbpsi_DetachCAT(dvbpsi_t *p_dvbpsi)
*****************************************************************************/ *****************************************************************************/
void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, uint8_t i_version, bool b_current_next) void dvbpsi_InitCAT(dvbpsi_cat_t* p_cat, uint8_t i_version, bool b_current_next)
{ {
assert(p_cat);
p_cat->i_version = i_version; p_cat->i_version = i_version;
p_cat->b_current_next = b_current_next; p_cat->b_current_next = b_current_next;
p_cat->p_first_descriptor = NULL; p_cat->p_first_descriptor = NULL;
...@@ -250,7 +257,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi, ...@@ -250,7 +257,7 @@ void dvbpsi_GatherCATSections(dvbpsi_t *p_dvbpsi,
/* Free structures */ /* Free structures */
if (p_cat_decoder->p_building_cat) if (p_cat_decoder->p_building_cat)
{ {
free(p_cat_decoder->p_building_cat); dvbpsi_DeleteCAT(p_cat_decoder->p_building_cat);
p_cat_decoder->p_building_cat = NULL; p_cat_decoder->p_building_cat = NULL;
} }
/* Clear the section array */ /* Clear the section array */
......
...@@ -127,15 +127,18 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -127,15 +127,18 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
dvbpsi_eit_decoder_t* p_eit_decoder; dvbpsi_eit_decoder_t* p_eit_decoder;
p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_decoder; p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_decoder;
free(p_eit_decoder->p_building_eit); if (p_eit_decoder->p_building_eit)
dvbpsi_DeleteEIT(p_eit_decoder->p_building_eit);
p_eit_decoder->p_building_eit = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
if (p_eit_decoder->ap_sections[i]) if (p_eit_decoder->ap_sections[i])
{
dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]);
p_eit_decoder->ap_sections[i] = NULL;
}
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec); dvbpsi_DeleteDemuxSubDecoder(p_subdec);
...@@ -355,13 +358,13 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de ...@@ -355,13 +358,13 @@ void dvbpsi_GatherEITSections(dvbpsi_t *p_dvbpsi, dvbpsi_decoder_t *p_private_de
/* Free structures */ /* Free structures */
if (p_eit_decoder->p_building_eit) if (p_eit_decoder->p_building_eit)
{ {
free(p_eit_decoder->p_building_eit); dvbpsi_DeleteEIT(p_eit_decoder->p_building_eit);
p_eit_decoder->p_building_eit = NULL; p_eit_decoder->p_building_eit = NULL;
} }
/* Clear the section array */ /* Clear the section array */
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
if(p_eit_decoder->ap_sections[i] != NULL) if (p_eit_decoder->ap_sections[i] != NULL)
{ {
dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]);
p_eit_decoder->ap_sections[i] = NULL; p_eit_decoder->ap_sections[i] = NULL;
......
...@@ -116,7 +116,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -116,7 +116,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if(p_demux == NULL) if (p_subdec == NULL)
{ {
dvbpsi_error(p_dvbpsi, "NIT Decoder", dvbpsi_error(p_dvbpsi, "NIT Decoder",
"No such NIT decoder (table_id == 0x%02x," "No such NIT decoder (table_id == 0x%02x,"
...@@ -127,15 +127,18 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -127,15 +127,18 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
dvbpsi_nit_decoder_t* p_nit_decoder; dvbpsi_nit_decoder_t* p_nit_decoder;
p_nit_decoder = (dvbpsi_nit_decoder_t*)p_subdec->p_decoder; p_nit_decoder = (dvbpsi_nit_decoder_t*)p_subdec->p_decoder;
free(p_nit_decoder->p_building_nit); if (p_nit_decoder->p_building_nit)
dvbpsi_DeleteNIT(p_nit_decoder->p_building_nit);
p_nit_decoder->p_building_nit = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
if (p_nit_decoder->ap_sections[i]) if (p_nit_decoder->ap_sections[i])
{
dvbpsi_DeletePSISections(p_nit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_nit_decoder->ap_sections[i]);
p_nit_decoder->ap_sections[i] = NULL;
}
} }
free(p_subdec->p_decoder);
p_subdec->p_decoder = NULL;
/* Free demux sub table decoder */ /* Free demux sub table decoder */
dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
...@@ -373,7 +376,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi, ...@@ -373,7 +376,7 @@ void dvbpsi_GatherNITSections(dvbpsi_t *p_dvbpsi,
/* Free structures */ /* Free structures */
if(p_nit_decoder->p_building_nit) if(p_nit_decoder->p_building_nit)
{ {
free(p_nit_decoder->p_building_nit); dvbpsi_DeleteNIT(p_nit_decoder->p_building_nit);
p_nit_decoder->p_building_nit = NULL; p_nit_decoder->p_building_nit = NULL;
} }
/* Clear the section array */ /* Clear the section array */
......
...@@ -89,15 +89,18 @@ void dvbpsi_DetachPAT(dvbpsi_t *p_dvbpsi) ...@@ -89,15 +89,18 @@ void dvbpsi_DetachPAT(dvbpsi_t *p_dvbpsi)
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_pat_decoder_t* p_pat_decoder = (dvbpsi_pat_decoder_t*)p_dvbpsi->p_private; dvbpsi_pat_decoder_t* p_pat_decoder = (dvbpsi_pat_decoder_t*)p_dvbpsi->p_private;
free(p_pat_decoder->p_building_pat); if (p_pat_decoder->p_building_pat)
dvbpsi_DeletePAT(p_pat_decoder->p_building_pat);
p_pat_decoder->p_building_pat = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
if (p_pat_decoder->ap_sections[i]) if (p_pat_decoder->ap_sections[i])
free(p_pat_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_pat_decoder->ap_sections[i]);
p_pat_decoder->ap_sections[i] = NULL;
} }
dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private); dvbpsi_DeleteDecoder(p_dvbpsi->p_private);
p_dvbpsi->p_private = NULL; p_dvbpsi->p_private = NULL;
} }
...@@ -204,7 +207,7 @@ static void dvbpsi_ReInitPAT(dvbpsi_pat_decoder_t* p_pat_decoder, const bool b_f ...@@ -204,7 +207,7 @@ static void dvbpsi_ReInitPAT(dvbpsi_pat_decoder_t* p_pat_decoder, const bool b_f
/* Free structures */ /* Free structures */
if (p_pat_decoder->p_building_pat) if (p_pat_decoder->p_building_pat)
free(p_pat_decoder->p_building_pat); dvbpsi_DeletePAT(p_pat_decoder->p_building_pat);
} }
p_pat_decoder->p_building_pat = NULL; p_pat_decoder->p_building_pat = NULL;
......
...@@ -92,12 +92,15 @@ void dvbpsi_DetachPMT(dvbpsi_t *p_dvbpsi) ...@@ -92,12 +92,15 @@ void dvbpsi_DetachPMT(dvbpsi_t *p_dvbpsi)
dvbpsi_pmt_decoder_t* p_pmt_decoder; dvbpsi_pmt_decoder_t* p_pmt_decoder;
p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private; p_pmt_decoder = (dvbpsi_pmt_decoder_t*)p_dvbpsi->p_private;
free(p_pmt_decoder->p_building_pmt); if (p_pmt_decoder->p_building_pmt)
dvbpsi_DeletePMT(p_pmt_decoder->p_building_pmt);
p_pmt_decoder->p_building_pmt = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
if (p_pmt_decoder->ap_sections[i]) if (p_pmt_decoder->ap_sections[i])
free(p_pmt_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_pmt_decoder->ap_sections[i]);
p_pmt_decoder->ap_sections[i] = NULL;
} }
dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private); dvbpsi_DeleteDecoder((dvbpsi_decoder_t *)p_dvbpsi->p_private);
...@@ -265,7 +268,7 @@ static void dvbpsi_ReInitPMT(dvbpsi_pmt_decoder_t* p_decoder, const bool b_force ...@@ -265,7 +268,7 @@ static void dvbpsi_ReInitPMT(dvbpsi_pmt_decoder_t* p_decoder, const bool b_force
/* Free structures */ /* Free structures */
if (p_decoder->p_building_pmt) if (p_decoder->p_building_pmt)
free(p_decoder->p_building_pmt); dvbpsi_DeletePMT(p_decoder->p_building_pmt);
} }
p_decoder->p_building_pmt = NULL; p_decoder->p_building_pmt = NULL;
......
...@@ -128,7 +128,9 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -128,7 +128,9 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_sdt_decoder_t* p_sdt_decoder; dvbpsi_sdt_decoder_t* p_sdt_decoder;
p_sdt_decoder = (dvbpsi_sdt_decoder_t*)p_subdec->p_decoder; p_sdt_decoder = (dvbpsi_sdt_decoder_t*)p_subdec->p_decoder;
free(p_sdt_decoder->p_building_sdt); if (p_sdt_decoder->p_building_sdt)
dvbpsi_DeleteSDT(p_sdt_decoder->p_building_sdt);
p_sdt_decoder->p_building_sdt = NULL;
for (unsigned int i = 0; i <= 255; i++) for (unsigned int i = 0; i <= 255; i++)
{ {
...@@ -283,7 +285,7 @@ static void dvbpsi_ReInitSDT(dvbpsi_sdt_decoder_t* p_decoder, const bool b_force ...@@ -283,7 +285,7 @@ static void dvbpsi_ReInitSDT(dvbpsi_sdt_decoder_t* p_decoder, const bool b_force
/* Free structures */ /* Free structures */
if (p_decoder->p_building_sdt) if (p_decoder->p_building_sdt)
free(p_decoder->p_building_sdt); dvbpsi_DeleteSDT(p_decoder->p_building_sdt);
} }
p_decoder->p_building_sdt = NULL; p_decoder->p_building_sdt = NULL;
...@@ -298,13 +300,12 @@ static void dvbpsi_ReInitSDT(dvbpsi_sdt_decoder_t* p_decoder, const bool b_force ...@@ -298,13 +300,12 @@ static void dvbpsi_ReInitSDT(dvbpsi_sdt_decoder_t* p_decoder, const bool b_force
} }
} }
static bool dvbpsi_CheckSDT(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t *p_section) static bool dvbpsi_CheckSDT(dvbpsi_t *p_dvbpsi, dvbpsi_sdt_decoder_t *p_sdt_decoder,
dvbpsi_psi_section_t *p_section)
{ {
bool b_reinit = false; bool b_reinit = false;
assert(p_dvbpsi->p_private); assert(p_dvbpsi);
assert(p_sdt_decoder);
dvbpsi_sdt_decoder_t* p_sdt_decoder;
p_sdt_decoder = (dvbpsi_sdt_decoder_t *)p_dvbpsi->p_private;
if (p_sdt_decoder->p_building_sdt->i_ts_id != p_section->i_extension) if (p_sdt_decoder->p_building_sdt->i_ts_id != p_section->i_extension)
{ {
...@@ -416,7 +417,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi, ...@@ -416,7 +417,7 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
/* Perform a few sanity checks */ /* Perform a few sanity checks */
if (p_sdt_decoder->p_building_sdt) if (p_sdt_decoder->p_building_sdt)
{ {
if (dvbpsi_CheckSDT(p_dvbpsi, p_section)) if (dvbpsi_CheckSDT(p_dvbpsi, p_sdt_decoder, p_section))
dvbpsi_ReInitSDT(p_sdt_decoder, true); dvbpsi_ReInitSDT(p_sdt_decoder, true);
} }
else else
...@@ -426,6 +427,9 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi, ...@@ -426,6 +427,9 @@ void dvbpsi_GatherSDTSections(dvbpsi_t *p_dvbpsi,
&& (p_sdt_decoder->current_sdt.b_current_next == p_section->b_current_next)) && (p_sdt_decoder->current_sdt.b_current_next == p_section->b_current_next))
{ {
/* Don't decode since this version is already decoded */ /* Don't decode since this version is already decoded */
dvbpsi_debug(p_dvbpsi, "SDT decoder",
"ignoring already decoded section %d",
p_section->i_number);
dvbpsi_DeletePSISections(p_section); dvbpsi_DeletePSISections(p_section);
return; return;
} }
......
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