[FFmpeg-devel] [PATCH 2/4] avutil/opt: set_string: allow src=dst

Michael Niedermayer michaelni at gmx.at
Sun Jun 1 18:50:33 CEST 2014


On Sun, Jun 01, 2014 at 03:52:06PM +0200, Nicolas George wrote:
> Le primidi 11 prairial, an CCXXII, Michael Niedermayer a écrit :
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavutil/opt.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavutil/opt.c b/libavutil/opt.c
> > index b4dd0fd..72de041 100644
> > --- a/libavutil/opt.c
> > +++ b/libavutil/opt.c
> > @@ -181,7 +181,8 @@ static int set_string_binary(void *obj, const AVOption *o, const char *val, uint
> >  
> >  static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst)
> >  {
> > -    av_freep(dst);
> > +    if (*dst != val)
> > +        av_freep(dst);
> >      *dst = av_strdup(val);
> >      return 0;
> >  }
> 
> The whole patch series seems like a good idea. Can you explain in what case
> exactly this one is needed? It seems a bit tricky to use due to possible
> leaks.

in the case where the old context is copied to a new place
and then fields in it changed from a copy of pointers to a
properly sepeartly allocated one, but maybe its not needed by this
patch series, id have to retest

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140601/c7510485/attachment.asc>


More information about the ffmpeg-devel mailing list