On 05/15/2013 09:30 AM, Martin Storsjö wrote:
> From: Michael Niedermayer <[email protected]>
> 
> This fixes out of array accesses.
> 
> Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind


Looks like a bandaid, the specification makes impossible switching mode?

> 
> ---
> Ok'd by Mashiat in a comment on github:
> https://github.com/mstorsjo/libav/commit/e6e097ee9c9325df68d070f37471081870d5c76a#commitcomment-3211959
> ---
>  libavcodec/vc1.c    |   17 +++++++++++------
>  libavcodec/vc1.h    |    1 +
>  libavcodec/vc1dec.c |    2 ++
>  3 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
> index 25e3579..adc75e3 100644
> --- a/libavcodec/vc1.c
> +++ b/libavcodec/vc1.c
> @@ -825,6 +825,7 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, 
> GetBitContext* gb)
>      int status;
>      int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only 
> for debugging */
>      int scale, shift, i; /* for initializing LUT for intensity compensation 
> */
> +    int field_mode, fcm;
>  
>      v->p_frame_skipped = 0;
>      if (v->second_field) {
> @@ -836,19 +837,23 @@ int ff_vc1_parse_frame_header_adv(VC1Context *v, 
> GetBitContext* gb)
>              goto parse_common_info;
>      }
>  
> -    v->field_mode = 0;
> +    field_mode = 0;
>      if (v->interlace) {
> -        v->fcm = decode012(gb);
> -        if (v->fcm) {
> -            if (v->fcm == ILACE_FIELD)
> -                v->field_mode = 1;
> +        fcm = decode012(gb);
> +        if (fcm) {
> +            if (fcm == ILACE_FIELD)
> +                field_mode = 1;
>              if (!v->warn_interlaced++)
>                  av_log(v->s.avctx, AV_LOG_ERROR,
>                         "Interlaced frames/fields support is incomplete\n");
>          }
>      } else {
> -        v->fcm = PROGRESSIVE;
> +        fcm = PROGRESSIVE;
>      }
> +    if (!v->first_pic_header_flag && v->field_mode != field_mode)

A message such as

av_log(v->s.avctx, AV_LOG_ERROR, "Switching field mode is not supported\n");

> +        return -1;

return AVERROR(ENOSYS); (or patch welcome)

Might be a good idea.

lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to