[vlc-devel] [PATCH] vt_utils: implements picture context copy

Thomas Guillem thomas at gllm.fr
Wed Jun 7 09:01:34 CEST 2017



On Tue, Jun 6, 2017, at 18:49, Rémi Denis-Courmont wrote:
> Le tiistaina 6. kesäkuuta 2017, 11.53.53 EEST Thomas Guillem a écrit :
> > ---
> >  modules/codec/vt_utils.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/modules/codec/vt_utils.c b/modules/codec/vt_utils.c
> > index 3f2e79da93..3faf8598dd 100644
> > --- a/modules/codec/vt_utils.c
> > +++ b/modules/codec/vt_utils.c
> > @@ -55,6 +55,18 @@ cvpxpic_destroy_cb(picture_context_t *opaque)
> >      free(opaque);
> >  }
> > 
> > +static picture_context_t *
> > +cvpxpic_copy_cb(struct picture_context_t *opaque)
> > +{
> > +    struct cvpxpic_ctx *src_ctx = (struct cvpxpic_ctx *)opaque;
> > +    struct cvpxpic_ctx *dst_ctx = malloc(sizeof(struct cvpxpic_ctx));
> > +    if (dst_ctx == NULL)
> > +        return NULL;
> > +    *dst_ctx = *src_ctx;
> > +    dst_ctx->cvpx = CVPixelBufferRetain(dst_ctx->cvpx);
> > +    return &dst_ctx->s;
> > +}
> 
> AFAICT, you don´t need to malloc() here. You can just increase the
> reference 
> count and return the same object.

Then I'll have a memory corruption if the src picture is released before
the dst one. My context is freed from context->destroy(). I checked,
there is no way to check if the refcount is 0 after a release.

> 
> -- 
> 雷米‧德尼-库尔蒙
> https://www.remlab.net/
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list