From b616a6cef17dd77b485c1ae20be8732038535c82 Mon Sep 17 00:00:00 2001 From: NRK Date: Thu, 29 Jun 2023 04:07:08 +0600 Subject: [PATCH] vo_x11: don't rely on XFree to free calloc-ed data --- video/out/vo_x11.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 42b7c7f5da..3579a3034b 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -153,8 +153,13 @@ static void freeMyXImage(struct priv *p, int foo) XDestroyImage(p->myximage[foo]); shmdt(p->Shminfo[foo].shmaddr); } else { - if (p->myximage[foo]) + if (p->myximage[foo]) { + // XDestroyImage() would free the data too since XFree() just calls + // free(), but do it ourselves for portability reasons + free(p->myximage[foo]->data); + p->myximage[foo]->data = NULL; XDestroyImage(p->myximage[foo]); + } } p->myximage[foo] = NULL; }