From 43d844eca4d3c705d19c8922f71932fc5882a0be Mon Sep 17 00:00:00 2001 From: Adam Halim Date: Mon, 12 Jun 2023 10:44:43 +0200 Subject: [PATCH] Fix shared memory leak The MIT-SHM documentation: https://www.x.org/releases/X11R7.7/doc/xextproto/shm.html says to run XShmDetach() first, and then to destroy the segment. (cherry picked from commit 585ee24d4cd81759ca7206d5d5181a491c2e8898) --- unix/x0vncserver/Image.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/x0vncserver/Image.cxx b/unix/x0vncserver/Image.cxx index 92d629f3..755da787 100644 --- a/unix/x0vncserver/Image.cxx +++ b/unix/x0vncserver/Image.cxx @@ -312,8 +312,8 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo) ShmImage::~ShmImage() { - // FIXME: Destroy image as described in MIT-SHM documentation. if (shminfo != NULL) { + XShmDetach(dpy, shminfo); shmdt(shminfo->shmaddr); shmctl(shminfo->shmid, IPC_RMID, 0); delete shminfo; -- 2.39.5