[vlc-devel] [PATCH] demux/playlist: wpl: reimplement parsing
Francois Cartegnie
fcvlcdev at free.fr
Fri Mar 17 09:43:50 CET 2017
Le 15/03/2017 à 10:07, Filip Roséen a écrit :
> The previous implementation suffered from a bunch of different issues,
> mostly related to not properly checking errors and the current state
> of the XML-parser.
>
> This new implementation is somewhat more verbose, but manages things
> in a correct manner:
>
> - prevents infinite loops on unexpected data
> - prevents memory corruption on unexpected data
> - prevents memory-leaks on error
> +static int consume_tag( xml_reader_t* p_reader, char const* psz_tag )
> +{
> + int i_type, i_depth = 0;
> + char const *psz_name;
> +
> + if( xml_ReaderIsEmptyElement( p_reader ) == 1 )
> + return VLC_SUCCESS;
> +
> + while( ( i_type = xml_ReaderNextNode( p_reader, &psz_name ) ) > 0 )
> + {
> + if( i_type == XML_READER_ENDELEM && !strcasecmp( psz_name, psz_tag ) )
> + {
> + if( --i_depth < 0 )
> + return VLC_SUCCESS;
> + }
> + else if( i_type == XML_READER_STARTELEM && !strcasecmp( psz_name, psz_tag ) )
> + ++i_depth;
> + }
> +
> + return VLC_EGENERIC;
> +}
And fails on the usual empty tag.
Francois
More information about the vlc-devel
mailing list