[FFmpeg-devel] [PATCH] vf_pullup: simplify, fix double free error

wm4 nfxjfg at googlemail.com
Wed Mar 26 12:28:55 CET 2014


On Tue, 25 Mar 2014 16:56:47 +0100
Michael Niedermayer <michaelni at gmx.at> wrote:

> > -static void free_field_queue(PullupField *head, PullupField **last)
> > +static void free_field_queue(PullupField *head)
> >  {
> >      PullupField *f = head;
> > -    while (f) {
> > +    do {
> > +        PullupField *next;
> > +        if (!f)
> > +            break;
> >          av_free(f->diffs);
> >          av_free(f->combs);
> >          av_free(f->vars);
> > -        if (f == *last) {
> > -            av_freep(last);
> > -            break;
> > -        }
> > -        f = f->next;
> > -        av_freep(&f->prev);
> > -    };
> > +        next = f->next;
> > +        av_free(f);
> > +        f = next;
> > +    } while (f != head);
> >  }
> 
> i would suggest to set freed pointers to NULL, this should make it
> more robust
> also might mke the != head check unneeded

From what I can see, it doesn't. It's still a ring. I attached a patch
on top of my previous patch, that turns the ring into a linear list. But
I don't think it's much of an improvement, and it reduces the code only
by 1 line.

Anyway, the problem with vf_pullup as it is in master is that s->last
does not necessarily point to s->head->prev (and can even be NULL), and
my previous patch fixes that, so the patch I'm sending with this mail is
purely cosmetic.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vf_pullup-slightly-easier-to-follow-cleanup-code.patch
Type: text/x-patch
Size: 1086 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140326/f6b75919/attachment.bin>


More information about the ffmpeg-devel mailing list