Commit 65dcdf8b authored by Gildas Bazin's avatar Gildas Bazin

* ALL: bunch of bug and mem-leak fixes.

parent bddeded3
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* demux.c: DVB subtables demux functions. * demux.c: DVB subtables demux functions.
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* (c)2001-2002 VideoLAN * (c)2001-2002 VideoLAN
* $Id: demux.c,v 1.2 2003/09/23 13:04:54 tooney Exp $ * $Id$
* *
* Authors: Johan Bilien <jobi@via.ecp.fr> * Authors: Johan Bilien <jobi@via.ecp.fr>
* *
...@@ -159,9 +159,14 @@ void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi) ...@@ -159,9 +159,14 @@ void dvbpsi_DetachDemux(dvbpsi_handle h_dvbpsi)
{ {
p_subdec_temp = p_subdec; p_subdec_temp = p_subdec;
p_subdec = p_subdec->p_next; p_subdec = p_subdec->p_next;
free(p_subdec_temp); if(p_subdec_temp->pf_detach)
p_subdec_temp->pf_detach(p_demux, (p_subdec_temp->i_id >> 16) & 0xFFFF,
p_subdec_temp->i_id & 0xFFFF);
else free(p_subdec_temp);
} }
free(p_demux); free(p_demux);
if(h_dvbpsi->p_current_section)
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section);
free(h_dvbpsi); free(h_dvbpsi);
} }
/***************************************************************************** /*****************************************************************************
* demux.h * demux.h
* (c)2001-2002 VideoLAN * (c)2001-2002 VideoLAN
* $Id: demux.h,v 1.1 2002/12/11 13:04:56 jobi Exp $ * $Id$
* *
* Authors: Johan Bilien <jobi@via.ecp.fr> * Authors: Johan Bilien <jobi@via.ecp.fr>
* *
...@@ -81,12 +81,15 @@ typedef void (*dvbpsi_demux_subdec_cb_t) ...@@ -81,12 +81,15 @@ typedef void (*dvbpsi_demux_subdec_cb_t)
* \typedef struct dvbpsi_demux_subdec_s dvbpsi_demux_subdec_t * \typedef struct dvbpsi_demux_subdec_s dvbpsi_demux_subdec_t
* \brief dvbpsi_demux_subdec_t type definition. * \brief dvbpsi_demux_subdec_t type definition.
*/ */
struct dvbpsi_demux_s;
typedef struct dvbpsi_demux_subdec_s typedef struct dvbpsi_demux_subdec_s
{ {
uint32_t i_id; uint32_t i_id;
dvbpsi_demux_subdec_cb_t pf_callback; dvbpsi_demux_subdec_cb_t pf_callback;
void * p_cb_data; void * p_cb_data;
struct dvbpsi_demux_subdec_s * p_next; struct dvbpsi_demux_subdec_s * p_next;
void (*pf_detach)(struct dvbpsi_demux_s *, uint8_t, uint16_t);
} dvbpsi_demux_subdec_t; } dvbpsi_demux_subdec_t;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* psi.c: common PSI functions * psi.c: common PSI functions
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* (c)2001-2002 VideoLAN * (c)2001-2002 VideoLAN
* $Id: psi.c,v 1.4 2002/10/07 14:15:14 sam Exp $ * $Id$
* *
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> * Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* *
...@@ -160,7 +160,7 @@ dvbpsi_psi_section_t * dvbpsi_NewPSISection(int i_max_size) ...@@ -160,7 +160,7 @@ dvbpsi_psi_section_t * dvbpsi_NewPSISection(int i_max_size)
else else
{ {
free(p_section); free(p_section);
p_section = NULL; return NULL;
} }
p_section->p_next = NULL; p_section->p_next = NULL;
......
...@@ -89,6 +89,7 @@ int dvbpsi_AttachEIT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id, ...@@ -89,6 +89,7 @@ int dvbpsi_AttachEIT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
p_subdec->pf_callback = &dvbpsi_GatherEITSections; p_subdec->pf_callback = &dvbpsi_GatherEITSections;
p_subdec->p_cb_data = p_eit_decoder; p_subdec->p_cb_data = p_eit_decoder;
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension;
p_subdec->pf_detach = dvbpsi_DetachEIT;
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; p_subdec->p_next = p_demux->p_first_subdec;
...@@ -116,7 +117,7 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, ...@@ -116,7 +117,7 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t* p_next_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_eit_decoder_t* p_eit_decoder; dvbpsi_eit_decoder_t* p_eit_decoder;
unsigned int i; unsigned int i;
...@@ -132,8 +133,6 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, ...@@ -132,8 +133,6 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
return; return;
} }
p_next_subdec = p_subdec->p_next;
p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_cb_data; p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_cb_data;
free(p_eit_decoder->p_building_eit); free(p_eit_decoder->p_building_eit);
...@@ -141,12 +140,17 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, ...@@ -141,12 +140,17 @@ void dvbpsi_DetachEIT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
for(i = 0; i <= 255; i++) for(i = 0; i <= 255; i++)
{ {
if(p_eit_decoder->ap_sections[i]) if(p_eit_decoder->ap_sections[i])
free(p_eit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
pp_prev_subdec = &p_demux->p_first_subdec;
while(*pp_prev_subdec != p_subdec)
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec); free(p_subdec);
p_subdec = p_next_subdec;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pat.c: PAT decoder/generator * pat.c: PAT decoder/generator
*---------------------------------------------------------------------------- *----------------------------------------------------------------------------
* (c)2001-2002 VideoLAN * (c)2001-2002 VideoLAN
* $Id: pat.c,v 1.4 2002/10/10 09:27:02 sam Exp $ * $Id$
* *
* Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr> * Authors: Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* *
...@@ -108,6 +108,8 @@ void dvbpsi_DetachPAT(dvbpsi_handle h_dvbpsi) ...@@ -108,6 +108,8 @@ void dvbpsi_DetachPAT(dvbpsi_handle h_dvbpsi)
} }
free(h_dvbpsi->p_private_decoder); free(h_dvbpsi->p_private_decoder);
if(h_dvbpsi->p_current_section)
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section);
free(h_dvbpsi); free(h_dvbpsi);
} }
......
...@@ -112,6 +112,8 @@ void dvbpsi_DetachPMT(dvbpsi_handle h_dvbpsi) ...@@ -112,6 +112,8 @@ void dvbpsi_DetachPMT(dvbpsi_handle h_dvbpsi)
} }
free(h_dvbpsi->p_private_decoder); free(h_dvbpsi->p_private_decoder);
if(h_dvbpsi->p_current_section)
dvbpsi_DeletePSISections(h_dvbpsi->p_current_section);
free(h_dvbpsi); free(h_dvbpsi);
} }
......
...@@ -88,6 +88,7 @@ int dvbpsi_AttachSDT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id, ...@@ -88,6 +88,7 @@ int dvbpsi_AttachSDT(dvbpsi_decoder_t * p_psi_decoder, uint8_t i_table_id,
p_subdec->pf_callback = &dvbpsi_GatherSDTSections; p_subdec->pf_callback = &dvbpsi_GatherSDTSections;
p_subdec->p_cb_data = p_sdt_decoder; p_subdec->p_cb_data = p_sdt_decoder;
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension;
p_subdec->pf_detach = dvbpsi_DetachSDT;
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; p_subdec->p_next = p_demux->p_first_subdec;
...@@ -115,7 +116,7 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, ...@@ -115,7 +116,7 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t* p_next_subdec; dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_sdt_decoder_t* p_sdt_decoder; dvbpsi_sdt_decoder_t* p_sdt_decoder;
unsigned int i; unsigned int i;
...@@ -131,8 +132,6 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, ...@@ -131,8 +132,6 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
return; return;
} }
p_next_subdec = p_subdec->p_next;
p_sdt_decoder = (dvbpsi_sdt_decoder_t*)p_subdec->p_cb_data; p_sdt_decoder = (dvbpsi_sdt_decoder_t*)p_subdec->p_cb_data;
free(p_sdt_decoder->p_building_sdt); free(p_sdt_decoder->p_building_sdt);
...@@ -140,12 +139,17 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id, ...@@ -140,12 +139,17 @@ void dvbpsi_DetachSDT(dvbpsi_demux_t * p_demux, uint8_t i_table_id,
for(i = 0; i <= 255; i++) for(i = 0; i <= 255; i++)
{ {
if(p_sdt_decoder->ap_sections[i]) if(p_sdt_decoder->ap_sections[i])
free(p_sdt_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_sdt_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
pp_prev_subdec = &p_demux->p_first_subdec;
while(*pp_prev_subdec != p_subdec)
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec); free(p_subdec);
p_subdec = p_next_subdec;
} }
......
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