[X2Go-Commits] [nx-libs] 76/219: Screen.c: correctly free stuff in nxagentCloseScreen

git-admin at x2go.org git-admin at x2go.org
Sat Sep 28 12:10:25 CEST 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch 3.6.x
in repository nx-libs.

commit 0f8dbbab2a218269165f06de37db59b5a20f09ea
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Fri Jun 14 00:14:17 2019 +0200

    Screen.c: correctly free stuff in nxagentCloseScreen
    
    fixes a memory leak:
    
    ==19074== 2 bytes in 1 blocks are definitely lost in loss record 8 of 313
    ==19074==    at 0x483577F: malloc (vg_replace_malloc.c:299)
    ==19074==    by 0x1FD83D: fbAllocatePrivates (fballpriv.c:79)
    ==19074==    by 0x20A666: fbSetupScreen (fbscreen.c:110)
    ==19074==    by 0x20A666: fbScreenInit (fbscreen.c:300)
    ==19074==    by 0x1DEA4C: nxagentOpenScreen (Screen.c:1356)
    ==19074==    by 0x16D7F8: AddScreen (dispatch.c:4257)
    ==19074==    by 0x1DA0CF: InitOutput (Init.c:397)
    ==19074==    by 0x14DCC2: main (main.c:280)
---
 nx-X11/programs/Xserver/hw/nxagent/Screen.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
index 8568562c2..7d180da44 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c
@@ -2141,20 +2141,32 @@ Bool nxagentCloseScreen(ScreenPtr pScreen)
   fprintf(stderr, "running nxagentCloseScreen()\n");
   #endif
 
+  /*
+   * We have called fbScreenInit() in nxagenOpenScreen, which in turn
+   * called fbOpenScreen. But we are not using the data as created by
+   * fbOpenScreen but have freed it and replaced by our own. So we free
+   * our own stuff here and take care that fbCloseScreen will not free
+   * them again.
+   */
+
   for (i = 0; i < pScreen->numDepths; i++)
   {
     free(pScreen->allowedDepths[i].vids);
+    pScreen->allowedDepths[i].vids = NULL;
   }
 
+  pScreen->numDepths = 0;
+
   /*
    * Free the frame buffer.
    */
 
   free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr);
+  free(pScreen->devPrivate);pScreen->devPrivate = NULL;
+  free(pScreen->allowedDepths); pScreen->allowedDepths = NULL;
+  free(pScreen->visuals); pScreen->visuals = NULL;
 
-  free(pScreen->allowedDepths);
-  free(pScreen->visuals);
-  free(pScreen->devPrivate);
+  fbCloseScreen(pScreen);
 
   /*
    * Reset the geometry and alpha information

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/nx-libs.git


More information about the x2go-commits mailing list