[FFmpeg-devel] [PATCH] pgssubdec: only set w/h/linesize when allocating data

wm4 nfxjfg at googlemail.com
Wed Nov 23 15:48:39 EET 2016


On Wed, 9 Nov 2016 23:27:04 +0100
Andreas Cadhalpun <andreas.cadhalpun at googlemail.com> wrote:

> Rects with positive w/h/linesize but no data are invalid.
> 
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  libavcodec/pgssubdec.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
> index cef477d..b50b37b 100644
> --- a/libavcodec/pgssubdec.c
> +++ b/libavcodec/pgssubdec.c
> @@ -556,12 +556,13 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
>  
>          sub->rects[i]->x    = ctx->presentation.objects[i].x;
>          sub->rects[i]->y    = ctx->presentation.objects[i].y;
> -        sub->rects[i]->w    = object->w;
> -        sub->rects[i]->h    = object->h;
> -
> -        sub->rects[i]->linesize[0] = object->w;
>  
>          if (object->rle) {
> +            sub->rects[i]->w    = object->w;
> +            sub->rects[i]->h    = object->h;
> +
> +            sub->rects[i]->linesize[0] = object->w;
> +
>              if (object->rle_remaining_len) {
>                  av_log(avctx, AV_LOG_ERROR, "RLE data length %u is %u bytes shorter than expected\n",
>                         object->rle_data_len, object->rle_remaining_len);

Is there any indication that API users are fine with rects that have
w=h=0 (or that the API allows it), and that they don't access data with
memcpy? Seems a bit odd. Since error handling set w=h=0 before, it's
probably ok though.


More information about the ffmpeg-devel mailing list