Commit 1d28c605 authored by Rémi Duraffort's avatar Rémi Duraffort

podcast: fix object leak (and memleak) in case of error.

parent 937fa424
...@@ -106,14 +106,16 @@ static int Demux( demux_t *p_demux ) ...@@ -106,14 +106,16 @@ static int Demux( demux_t *p_demux )
INIT_PLAYLIST_STUFF; INIT_PLAYLIST_STUFF;
p_xml = p_sys->p_xml = xml_Create( p_demux ); p_xml = p_sys->p_xml = xml_Create( p_demux );
if( !p_xml ) return -1; if( !p_xml )
goto error;
/* psz_elname = stream_ReadLine( p_demux->s ); /* psz_elname = stream_ReadLine( p_demux->s );
if( psz_elname ) free( psz_elname ); if( psz_elname ) free( psz_elname );
psz_elname = 0;*/ psz_elname = 0;*/
p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s ); p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
if( !p_xml_reader ) return -1; if( !p_xml_reader )
goto error;
p_sys->p_xml_reader = p_xml_reader; p_sys->p_xml_reader = p_xml_reader;
/* xml */ /* xml */
...@@ -121,7 +123,7 @@ static int Demux( demux_t *p_demux ) ...@@ -121,7 +123,7 @@ static int Demux( demux_t *p_demux )
if( xml_ReaderRead( p_xml_reader ) != 1 ) if( xml_ReaderRead( p_xml_reader ) != 1 )
{ {
msg_Err( p_demux, "invalid file (no root node)" ); msg_Err( p_demux, "invalid file (no root node)" );
return -1; goto error;
} }
while( xml_ReaderNodeType( p_xml_reader ) == XML_READER_NONE ) while( xml_ReaderNodeType( p_xml_reader ) == XML_READER_NONE )
...@@ -129,7 +131,7 @@ static int Demux( demux_t *p_demux ) ...@@ -129,7 +131,7 @@ static int Demux( demux_t *p_demux )
if( xml_ReaderRead( p_xml_reader ) != 1 ) if( xml_ReaderRead( p_xml_reader ) != 1 )
{ {
msg_Err( p_demux, "invalid file (no root node)" ); msg_Err( p_demux, "invalid file (no root node)" );
return -1; goto error;
} }
} }
...@@ -139,8 +141,7 @@ static int Demux( demux_t *p_demux ) ...@@ -139,8 +141,7 @@ static int Demux( demux_t *p_demux )
{ {
msg_Err( p_demux, "invalid root node %i, %s", msg_Err( p_demux, "invalid root node %i, %s",
xml_ReaderNodeType( p_xml_reader ), psz_elname ); xml_ReaderNodeType( p_xml_reader ), psz_elname );
free( psz_elname ); goto error;
return -1;
} }
FREENULL( psz_elname ); FREENULL( psz_elname );
...@@ -152,15 +153,15 @@ static int Demux( demux_t *p_demux ) ...@@ -152,15 +153,15 @@ static int Demux( demux_t *p_demux )
{ {
// Error // Error
case -1: case -1:
return -1; goto error;
break;
case XML_READER_STARTELEM: case XML_READER_STARTELEM:
{ {
// Read the element name // Read the element name
free( psz_elname ); free( psz_elname );
psz_elname = xml_ReaderName( p_xml_reader ); psz_elname = xml_ReaderName( p_xml_reader );
if( !psz_elname ) return -1; if( !psz_elname )
goto error;
if( !strcmp( psz_elname, "item" ) ) if( !strcmp( psz_elname, "item" ) )
{ {
...@@ -180,8 +181,7 @@ static int Demux( demux_t *p_demux ) ...@@ -180,8 +181,7 @@ static int Demux( demux_t *p_demux )
{ {
free( psz_name ); free( psz_name );
free( psz_value ); free( psz_value );
free( psz_elname ); goto error;
return -1;
} }
if( !strcmp( psz_elname, "enclosure" ) ) if( !strcmp( psz_elname, "enclosure" ) )
...@@ -296,14 +296,14 @@ static int Demux( demux_t *p_demux ) ...@@ -296,14 +296,14 @@ static int Demux( demux_t *p_demux )
// Read the element name // Read the element name
free( psz_elname ); free( psz_elname );
psz_elname = xml_ReaderName( p_xml_reader ); psz_elname = xml_ReaderName( p_xml_reader );
if( !psz_elname ) return -1; if( !psz_elname )
goto error;
if( !strcmp( psz_elname, "item" ) ) if( !strcmp( psz_elname, "item" ) )
{ {
if( psz_item_mrl == NULL ) if( psz_item_mrl == NULL )
{ {
msg_Err( p_demux, "invalid XML (no enclosure markup)" ); msg_Err( p_demux, "invalid XML (no enclosure markup)" );
free( psz_elname ); goto error;
return -1;
} }
p_input = input_item_New( p_demux, psz_item_mrl, psz_item_name ); p_input = input_item_New( p_demux, psz_item_mrl, psz_item_name );
if( p_input == NULL ) break; if( p_input == NULL ) break;
...@@ -368,6 +368,23 @@ static int Demux( demux_t *p_demux ) ...@@ -368,6 +368,23 @@ static int Demux( demux_t *p_demux )
HANDLE_PLAY_AND_RELEASE; HANDLE_PLAY_AND_RELEASE;
return 0; /* Needed for correct operation of go back */ return 0; /* Needed for correct operation of go back */
error:
free( psz_item_name );
free( psz_item_mrl );
free( psz_item_size );
free( psz_item_type );
free( psz_item_date );
free( psz_item_author );
free( psz_item_category );
free( psz_item_duration );
free( psz_item_keywords );
free( psz_item_subtitle );
free( psz_item_summary );
free( psz_elname );
HANDLE_PLAY_AND_RELEASE;
return -1;
} }
static int Control( demux_t *p_demux, int i_query, va_list args ) static int Control( demux_t *p_demux, int i_query, va_list args )
......
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