Commit 2606a4da authored by Tristan Matthews's avatar Tristan Matthews

stream_filter: smooth: fix leaks (cid #1251056)

parent ab08d7de
...@@ -110,6 +110,16 @@ static void print_chunk( stream_t *s, chunk_t *ck ) ...@@ -110,6 +110,16 @@ static void print_chunk( stream_t *s, chunk_t *ck )
} }
#endif #endif
static void cleanup_attributes(custom_attrs_t **cp)
{
if( !*cp )
return;
free( (*cp)->psz_key );
free( (*cp)->psz_value );
FREENULL( *cp );
}
static int parse_Manifest( stream_t *s ) static int parse_Manifest( stream_t *s )
{ {
stream_sys_t *p_sys = s->p_sys; stream_sys_t *p_sys = s->p_sys;
...@@ -145,6 +155,7 @@ static int parse_Manifest( stream_t *s ) ...@@ -145,6 +155,7 @@ static int parse_Manifest( stream_t *s )
unsigned next_track_id = 1; unsigned next_track_id = 1;
int loop_count = 0; int loop_count = 0;
bool b_weird = false; bool b_weird = false;
int ret = VLC_SUCCESS;
#define TIMESCALE 10000000 #define TIMESCALE 10000000
while( (type = xml_ReaderNextNode( vlc_reader, &node )) > 0 ) while( (type = xml_ReaderNextNode( vlc_reader, &node )) > 0 )
...@@ -173,9 +184,8 @@ static int parse_Manifest( stream_t *s ) ...@@ -173,9 +184,8 @@ static int parse_Manifest( stream_t *s )
sms = sms_New(); sms = sms_New();
if( unlikely( !sms ) ) if( unlikely( !sms ) )
{ {
xml_ReaderDelete( vlc_reader ); ret = VLC_ENOMEM;
xml_Delete( vlc_xml ); goto cleanup;
return VLC_ENOMEM;
} }
sms->id = next_track_id; sms->id = next_track_id;
next_track_id++; next_track_id++;
...@@ -231,6 +241,11 @@ static int parse_Manifest( stream_t *s ) ...@@ -231,6 +241,11 @@ static int parse_Manifest( stream_t *s )
if (!sms || !ql || cp) if (!sms || !ql || cp)
break; break;
cp = (custom_attrs_t *) calloc( 1, sizeof(*cp) ); cp = (custom_attrs_t *) calloc( 1, sizeof(*cp) );
if( unlikely( !cp ) )
{
ret = VLC_ENOMEM;
goto cleanup;
}
} }
else if ( !strcmp( node, "Attribute" ) ) else if ( !strcmp( node, "Attribute" ) )
{ {
...@@ -253,10 +268,8 @@ static int parse_Manifest( stream_t *s ) ...@@ -253,10 +268,8 @@ static int parse_Manifest( stream_t *s )
ql = ql_New(); ql = ql_New();
if( !ql ) if( !ql )
{ {
sms_Free( sms ); ret = VLC_ENOMEM;
xml_ReaderDelete( vlc_reader ); goto cleanup;
xml_Delete( vlc_xml );
return VLC_ENOMEM;
} }
while( (name = xml_ReaderNextAttr( vlc_reader, &value )) ) while( (name = xml_ReaderNextAttr( vlc_reader, &value )) )
...@@ -358,10 +371,8 @@ static int parse_Manifest( stream_t *s ) ...@@ -358,10 +371,8 @@ static int parse_Manifest( stream_t *s )
if( unlikely( chunk_AppendNew( sms, computed_duration, if( unlikely( chunk_AppendNew( sms, computed_duration,
computed_start_time ) == NULL ) ) computed_start_time ) == NULL ) )
{ {
sms_Free( sms ); ret = VLC_ENOMEM;
xml_ReaderDelete( vlc_reader ); goto cleanup;
xml_Delete( vlc_xml );
return VLC_ENOMEM;
} }
if( b_weird && start_time != -1 ) if( b_weird && start_time != -1 )
computed_start_time = start_time; computed_start_time = start_time;
...@@ -381,9 +392,7 @@ static int parse_Manifest( stream_t *s ) ...@@ -381,9 +392,7 @@ static int parse_Manifest( stream_t *s )
{ {
if( !cp->psz_key || !cp->psz_value ) if( !cp->psz_key || !cp->psz_value )
{ {
free( cp->psz_key ); cleanup_attributes( &cp );
free( cp->psz_value );
FREENULL( cp );
} }
} }
else if( strcmp( node, "StreamIndex" ) ) else if( strcmp( node, "StreamIndex" ) )
...@@ -397,10 +406,8 @@ static int parse_Manifest( stream_t *s ) ...@@ -397,10 +406,8 @@ static int parse_Manifest( stream_t *s )
loop_count = 0; loop_count = 0;
if( b_weird && !chunk_AppendNew( sms, computed_duration, computed_start_time ) ) if( b_weird && !chunk_AppendNew( sms, computed_duration, computed_start_time ) )
{ {
sms_Free( sms ); ret = VLC_ENOMEM;
xml_ReaderDelete( vlc_reader ); goto cleanup;
xml_Delete( vlc_xml );
return VLC_ENOMEM;
} }
b_weird = false; b_weird = false;
...@@ -415,19 +422,19 @@ static int parse_Manifest( stream_t *s ) ...@@ -415,19 +422,19 @@ static int parse_Manifest( stream_t *s )
case XML_READER_TEXT: case XML_READER_TEXT:
break; break;
default: default:
sms_Free( sms ); ret = VLC_EGENERIC;
xml_ReaderDelete( vlc_reader ); goto cleanup;
xml_Delete( vlc_xml );
return VLC_EGENERIC;
} }
} }
#undef TIMESCALE #undef TIMESCALE
cleanup:
cleanup_attributes( &cp );
sms_Free( sms ); sms_Free( sms );
xml_ReaderDelete( vlc_reader ); xml_ReaderDelete( vlc_reader );
xml_Delete( vlc_xml ); xml_Delete( vlc_xml );
return VLC_SUCCESS; return ret;
} }
static void SysCleanup( stream_sys_t *p_sys ) static void SysCleanup( stream_sys_t *p_sys )
......
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