]> source.dussan.org Git - tigervnc.git/commitdiff
Fix shared memory leak 1722/head
authorAdam Halim <adaab301@student.liu.se>
Mon, 12 Jun 2023 08:44:43 +0000 (10:44 +0200)
committer= <adaab301@student.liu.se>
Fri, 26 Jan 2024 15:11:41 +0000 (16:11 +0100)
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

index 92d629f3aa3be326d1b31f1a5d5fbe1ab6a6377c..755da787a13b4ba2a12c1b059fc498a3cbed78df 100644 (file)
@@ -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;