[vlc-devel] [vlc-commits] subtitles: support MicroDVD size extension

Hugo Beauzée-Luyssen hugo at beauzee.fr
Wed Jun 29 13:28:05 CEST 2016


On 06/27/2016 03:37 PM, Jean-Baptiste Kempf wrote:
> vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jun 27 14:49:32 2016 +0200| [9dd890b3eab3fb4a03538cb078dd709a9924628c] | committer: Jean-Baptiste Kempf
>
> subtitles: support MicroDVD size extension
>
> Ref #1825
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9dd890b3eab3fb4a03538cb078dd709a9924628c
> ---
>
>  modules/codec/subsdec.c |   13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
> index 3949cd8..96c8a77 100644
> --- a/modules/codec/subsdec.c
> +++ b/modules/codec/subsdec.c
> @@ -984,6 +984,19 @@ static text_segment_t* ParseSubtitles( int *pi_align, const char *psz_subtitle )
>                  p_segment = NewTextSegmentPushStyle( p_segment, &p_stack );
>                  p_segment->style->psz_fontname = strndup( &psz_subtitle[3], i_len );
>              }
> +            else if( psz_subtitle[1] == 'S' || psz_subtitle[1] == 's' )
> +            {
> +                char *value = strndup( &psz_subtitle[3], i_len );

Why strdup? atoi("123garbage") will return 123
Which would also prevent 'value' from leaking

> +                int size = atoi( value );

> +                if( size )
> +                {
> +                    p_segment = NewTextSegmentPushStyle( p_segment, &p_stack );

This can fail

> +                    p_segment->style->i_font_size = size;
> +                    p_segment->style->f_font_relsize = STYLE_DEFAULT_REL_FONT_SIZE *
> +                                STYLE_DEFAULT_FONT_SIZE / p_segment->style->i_font_size;
> +
> +                }
> +            }
>              // Hide other {x:y} atrocities, like {c:$bbggrr} or {P:x}
>              psz_subtitle = psz_tag_end + 1;
>          }
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
>



More information about the vlc-devel mailing list