src/video_output/video_output.c: Fixed double free in filter removal

code
qt4/components/extended_panels.cpp: Improved some dagerous string
parsing code. This whole function looks very ad hoc to me at the
moment and should be rewritten in a more robust way. In particular
this function will misbehave if a video filter exists whose name is a
substring of another video filter. This change here just makes it less
likely to crash...
parent bf4ae068
......@@ -130,21 +130,28 @@ static void ChangeVFiltersString( intf_thread_t *p_intf,
{
if( psz_parser )
{
memmove( psz_parser, psz_parser + strlen(psz_name) +
(*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
strlen(psz_parser + strlen(psz_name)) + 1 );
if( *(psz_parser + strlen(psz_name)) == ':' )
{
memmove( psz_parser, psz_parser + strlen(psz_name) + 1,
strlen(psz_parser + strlen(psz_name) + 1 ) + 1 );
}
else
{
*psz_parser = '\0';
}
/* Remove trailing : : */
if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
if( strlen( psz_string ) > 0 &&
*( psz_string + strlen( psz_string ) -1 ) == ':' )
{
*(psz_string+strlen(psz_string ) -1 ) = '\0';
*( psz_string + strlen( psz_string ) -1 ) = '\0';
}
}
else
{
free( psz_string );
return;
}
}
else
{
free( psz_string );
return;
}
}
/* Vout is not kept, so put that in the config */
config_PutPsz( p_intf, "video-filter", psz_string );
......
......@@ -1549,7 +1549,11 @@ static int ParseVideoFilter2Chain( vout_thread_t *p_vout, char *psz_vfilters )
struct config_chain_t *p_cfg =
p_vout->p_vfilters_cfg[p_vout->i_vfilters_cfg];
config_ChainDestroy( p_cfg );
free( p_vout->psz_vfilters[p_vout->i_vfilters_cfg] );
if( p_vout->psz_vfilters[p_vout->i_vfilters_cfg] )
{
free( p_vout->psz_vfilters[p_vout->i_vfilters_cfg] );
p_vout->psz_vfilters[p_vout->i_vfilters_cfg] = NULL;
}
}
p_vout->i_vfilters_cfg = 0;
if( psz_vfilters && *psz_vfilters )
......
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