From aba77c64ffe098c4b1a000048adbfe282bb2cb0b Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Sun, 29 Nov 2020 14:07:43 +0200 Subject: vo_sixel: don't leak the frame reference The reference is allocated at reconfig and happens at least once (and leaked at least once), but can also be called more, e.g. on zoom or pan-and-scan changes. --- video/out/vo_sixel.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/video/out/vo_sixel.c b/video/out/vo_sixel.c index f4ba8db7c7..cc5cc34ecc 100644 --- a/video/out/vo_sixel.c +++ b/video/out/vo_sixel.c @@ -117,7 +117,7 @@ static int detect_scene_change(struct vo* vo) } -static void dealloc_dithers_and_buffer(struct vo* vo) +static void dealloc_dithers_and_buffers(struct vo* vo) { struct priv* priv = vo->priv; @@ -126,6 +126,11 @@ static void dealloc_dithers_and_buffer(struct vo* vo) priv->buffer = NULL; } + if (priv->frame) { + talloc_free(priv->frame); + priv->frame = NULL; + } + if (priv->dither) { sixel_dither_unref(priv->dither); priv->dither = NULL; @@ -288,6 +293,8 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) .p_h = 1, }; + dealloc_dithers_and_buffers(vo); + priv->frame = mp_image_alloc(IMGFMT, priv->width, priv->height); if (!priv->frame) return -1; @@ -299,8 +306,6 @@ static int reconfig(struct vo *vo, struct mp_image_params *params) printf(ESC_CLEAR_SCREEN); vo->want_redraw = true; - dealloc_dithers_and_buffer(vo); - // create testdither only if dynamic palette mode is set if (!priv->opt_fixedpal) { SIXELSTATUS status = sixel_dither_new(&priv->testdither, @@ -483,7 +488,7 @@ static void uninit(struct vo *vo) priv->output = NULL; } - dealloc_dithers_and_buffer(vo); + dealloc_dithers_and_buffers(vo); } #define OPT_BASE_STRUCT struct priv -- cgit v1.2.3