[FFmpeg-devel] [PATCH 04/15] libavcodec/wmadec: Return AVERROR_INVALIDDATA on decoding errors

Tomas Härdin git at haerdin.se
Wed Nov 20 17:32:47 EET 2024


> Needs a sample.

Actually, returning more sensible errors makes sense on its own even
without a sample. However:

> @@ -879,8 +881,10 @@ static int wma_decode_superframe(AVCodecContext *avctx, AVFrame *frame,
>                  return AVERROR_INVALIDDATA;
>  
>              if ((s->last_superframe_len + buf_size - 1) >
> -                MAX_CODED_SUPERFRAME_SIZE)
> +                MAX_CODED_SUPERFRAME_SIZE) {
> +                ret = -1;
>                  goto fail;
> +            }
>  
>              q   = s->last_superframe + s->last_superframe_len;
>              len = buf_size - 1;
> @@ -911,14 +915,17 @@ static int wma_decode_superframe(AVCodecContext *avctx, AVFrame *frame,
>              av_log(avctx, AV_LOG_ERROR,
>                     "Invalid last frame bit offset %d > buf size %d (%d)\n",
>                     bit_offset, get_bits_left(&s->gb), buf_size);
> +            ret = -1;
>              goto fail;
>          }
>  
>          if (s->last_superframe_len > 0) {
>              /* add bit_offset bits to last frame */
>              if ((s->last_superframe_len + ((bit_offset + 7) >> 3)) >
> -                MAX_CODED_SUPERFRAME_SIZE)
> +                MAX_CODED_SUPERFRAME_SIZE) {
> +                ret = -1;
>                  goto fail;
> +            }
> @@ -967,13 +974,14 @@ static int wma_decode_superframe(AVCodecContext *avctx, AVFrame *frame,
>          len               = buf_size - pos;
>          if (len > MAX_CODED_SUPERFRAME_SIZE || len < 0) {
>              av_log(s->avctx, AV_LOG_ERROR, "len %d invalid\n", len);
> +            ret = -1;

These should probably be ret = AVERROR_INVALIDDATA

/Tomas


More information about the ffmpeg-devel mailing list