[FFmpeg-devel] [PATCH 4/4] avcodec/qsvdec: Check av_image_get_buffer_size() for failure

Michael Niedermayer michael at niedermayer.cc
Sun May 19 22:50:32 EEST 2024


On Mon, May 13, 2024 at 01:47:36AM +0000, Xiang, Haihao wrote:
> On Ma, 2024-05-13 at 03:20 +0200, Michael Niedermayer wrote:
> > Fixes: CID1477406 Improper use of negative value
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  libavcodec/qsvdec.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> > index ed0bfe4c8b8..a51ddace622 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -379,9 +379,12 @@ static int qsv_decode_init_context(AVCodecContext *avctx,
> > QSVContext *q, mfxVide
> >  
> >      q->frame_info = param->mfx.FrameInfo;
> >  
> > -    if (!avctx->hw_frames_ctx)
> > -        q->pool = av_buffer_pool_init(av_image_get_buffer_size(avctx-
> > >pix_fmt,
> > -                    FFALIGN(avctx->width, 128), FFALIGN(avctx->height, 64),
> > 1), av_buffer_allocz);
> > +    if (!avctx->hw_frames_ctx) {
> > +        ret = av_image_get_buffer_size(avctx->pix_fmt, FFALIGN(avctx->width,
> > 128), FFALIGN(avctx->height, 64), 1);
> > +        if (ret < 0)
> > +            return ret;
> > +        q->pool = av_buffer_pool_init(ret, av_buffer_allocz);
> > +    }
> >      return 0;
> >  }
> >  
> 
> LGTM, thx

will apply

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Elect your leaders based on what they did after the last election, not
based on what they say before an election.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240519/ef870be9/attachment.sig>


More information about the ffmpeg-devel mailing list