From c669a434f3cb720868ed9aaf4af8d9fddb203d64 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 3 Oct 2019 01:07:25 +0200 Subject: [PATCH] vf_fingerprint: fix an obvious memory leak Leaks the entire zimg state on filter deinit. Not sure what I was thinking; with some luck, I just didn't give a shit about this case, but most likely I was thinking the same thing as always: nothing. --- video/filter/vf_fingerprint.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/video/filter/vf_fingerprint.c b/video/filter/vf_fingerprint.c index 6a6f7ab812..7061b74c3c 100644 --- a/video/filter/vf_fingerprint.c +++ b/video/filter/vf_fingerprint.c @@ -74,6 +74,16 @@ struct priv { void *zimg_tmp; }; +static void destroy_zimg(struct mp_filter *f) +{ + struct priv *p = f->priv; + + free(p->zimg_tmp); + p->zimg_tmp = NULL; + zimg_filter_graph_free(p->zimg_graph); + p->zimg_graph = NULL; +} + // (Other code internal to this filter also calls this to reset the frame list.) static void f_reset(struct mp_filter *f) { @@ -97,10 +107,7 @@ static void reinit_fmt(struct mp_filter *f, struct mp_image *mpi) p->last_w = mpi->w; p->last_h = mpi->h; - free(p->zimg_tmp); - p->zimg_tmp = NULL; - zimg_filter_graph_free(p->zimg_graph); - p->zimg_graph = NULL; + destroy_zimg(f); if (!(mpi->fmt.flags & (MP_IMGFLAG_YUV_NV | MP_IMGFLAG_YUV_P))) return; @@ -255,6 +262,7 @@ static const struct mp_filter_info filter = { .process = f_process, .command = f_command, .reset = f_reset, + .destroy = destroy_zimg, .priv_size = sizeof(struct priv), };