[FFmpeg-devel] [PATCH] avcodec/mationpixels: check for malloc failures

Michael Niedermayer michaelni at gmx.at
Sat Sep 14 04:19:10 CEST 2013


On Fri, Sep 13, 2013 at 11:12:42PM -0300, James Almer wrote:
> On 13/09/13 11:05 PM, Piotr Bandurski wrote:
> > From ca805e564cf0bb37d1068c4260a64240e5d82bd5 Mon Sep 17 00:00:00 2001
> > From: Piotr Bandurski <ami_stuff at o2.pl>
> > Date: Sat, 14 Sep 2013 04:03:11 +0200
> > Subject: [PATCH] avcodec/mationpixels: check for malloc failures
> > 
> > ---
> >  libavcodec/motionpixels.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
> > index 00c1148..1a62d47 100644
> > --- a/libavcodec/motionpixels.c
> > +++ b/libavcodec/motionpixels.c
> > @@ -68,6 +68,8 @@ static av_cold int mp_decode_init(AVCodecContext *avctx)
> >      mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
> >      mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel));
> >      mp->hpt = av_mallocz(h4 * w4 / 16 * sizeof(YuvPixel));
> > +    if (!mp->changes_map || !mp->vpt || !mp->hpt)
> > +        return AVERROR(ENOMEM);
> 
> av_freep() on all three, since one or two of them could have been successfully allocated.

didnt see the comment before pushing
but calling mp_decode_end() may be easier for post failure cleanup

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130914/fee45bdf/attachment.asc>


More information about the ffmpeg-devel mailing list