]> source.dussan.org Git - tigervnc.git/commitdiff
Fix for shared memory leakage. 402/head
authorTSUKAHARA Ken <ken3@nurs.or.jp>
Thu, 19 Jan 2017 15:21:39 +0000 (00:21 +0900)
committerTSUKAHARA Ken <ken3@nurs.or.jp>
Thu, 19 Jan 2017 15:21:39 +0000 (00:21 +0900)
vncviewer/X11PixelBuffer.cxx

index 4f52cad12cd0ac77afd4b122e9a9aaa135a27e22..e23f77719494a705f49186b050a65138a7b578b6 100644 (file)
@@ -187,8 +187,9 @@ int X11PixelBuffer::setupShm()
     goto free_xim;
 
   shminfo->shmaddr = xim->data = (char*)shmat(shminfo->shmid, 0, 0);
+  shmctl(shminfo->shmid, IPC_RMID, 0); // to avoid memory leakage
   if (shminfo->shmaddr == (char *)-1)
-    goto free_shm;
+    goto free_xim;
 
   shminfo->readOnly = True;
 
@@ -216,9 +217,6 @@ int X11PixelBuffer::setupShm()
 free_shmaddr:
   shmdt(shminfo->shmaddr);
 
-free_shm:
-  shmctl(shminfo->shmid, IPC_RMID, 0);
-
 free_xim:
   XDestroyImage(xim);
   xim = NULL;