From baf45b3bc99c5c307d0aa52ff83a9a365a054aed Mon Sep 17 00:00:00 2001 From: Shreesh Adiga <16567adigashreesh@gmail.com> Date: Mon, 9 Nov 2020 19:53:22 +0530 Subject: vo_sixel: Add checks to prevent null pointer dereferencing. --- video/out/vo_sixel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/video/out/vo_sixel.c b/video/out/vo_sixel.c index cce6a3da9d..5a5564edc1 100644 --- a/video/out/vo_sixel.c +++ b/video/out/vo_sixel.c @@ -162,7 +162,10 @@ static void dealloc_dithers_and_buffer(struct vo* vo) { struct priv* priv = vo->priv; - talloc_free(priv->buffer); + if (priv->buffer) { + talloc_free(priv->buffer); + priv->buffer = NULL; + } if (priv->dither) { sixel_dither_unref(priv->dither); @@ -296,6 +299,10 @@ static void flip_page(struct vo *vo) { struct priv* priv = vo->priv; + // Make sure that image and dither are valid before drawing + if (priv->buffer == NULL || priv->dither == NULL) + return; + // Go to the offset row and column, then display the image printf(ESC_GOTOXY, priv->top, priv->left); sixel_encode(priv->buffer, priv->width, priv->height, -- cgit v1.2.3