vo_sixel: Add checks to prevent null pointer dereferencing.

This commit is contained in:
Shreesh Adiga 2020-11-09 19:53:22 +05:30 committed by Avi Halachmi (:avih)
parent 8ddd4547fc
commit baf45b3bc9
1 changed files with 8 additions and 1 deletions

View File

@ -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,