[X2Go-Commits] [nx-libs] 80/219: Fix memleaks: Free devPrivates of devices on shutdown

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 4dd1f3cbdff984ff55bc2f88c64b2544c8d88148
Author: Ulrich Sibiller <uli42 at gmx.de>
Date:   Mon Jun 17 20:25:09 2019 +0200

    Fix memleaks: Free devPrivates of devices on shutdown
    
    Fixes these two memory leaks identified by valgrind:
    
    ==28336== 32 (8 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 180 of 308
    ==28336==    at 0x48356AF: malloc (vg_replace_malloc.c:298)
    ==28336==    by 0x4837DE7: realloc (vg_replace_malloc.c:826)
    ==28336==    by 0x1AE322: AllocateDevicePrivate (privates.c:439)
    ==28336==    by 0x27527B: XkbSetExtension (xkbActions.c:72)
    ==28336==    by 0x198E9B: _RegisterPointerDevice (devices.c:361)
    ==28336==    by 0x1DBA35: InitInput (Init.c:440)
    ==28336==    by 0x14DBD6: main (main.c:303)
    ==28336==
    ==28336== 32 (8 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 181 of 308
    ==28336==    at 0x48356AF: malloc (vg_replace_malloc.c:298)
    ==28336==    by 0x4837DE7: realloc (vg_replace_malloc.c:826)
    ==28336==    by 0x1AE322: AllocateDevicePrivate (privates.c:439)
    ==28336==    by 0x27527B: XkbSetExtension (xkbActions.c:72)
    ==28336==    by 0x198F1B: _RegisterKeyboardDevice (devices.c:384)
    ==28336==    by 0x1DBA3D: InitInput (Init.c:441)
    ==28336==    by 0x14DBD6: main (main.c:303)
---
 nx-X11/programs/Xserver/hw/nxagent/Keyboard.c |  9 ++++++++-
 nx-X11/programs/Xserver/hw/nxagent/Pointer.c  | 11 +++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index 46686b754..c8038955b 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -1025,11 +1025,18 @@ Reply   Total	Cached	Bits In			Bits Out		Bits/Reply	  Ratio
       break;
 
     case DEVICE_CLOSE:
-
       #ifdef TEST
       fprintf(stderr, "nxagentKeyboardProc: Called for [DEVICE_CLOSE].\n");
       #endif
 
+      for (int i = 0; i < pDev->nPrivates; i++)
+      {
+        free(pDev->devPrivates[i].ptr);
+        pDev->devPrivates[i].ptr = NULL;
+      }
+      free(pDev->devPrivates);
+      pDev->devPrivates = NULL;
+
       break;
   }
 
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c
index c59230724..85d286b96 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c
@@ -40,7 +40,7 @@ is" without express or implied warranty.
 #include "X.h"
 #include "Xproto.h"
 #include "screenint.h"
-#include "input.h"
+#include "inputstr.h"
 #include "misc.h"
 #include "scrnintstr.h"
 #include "servermd.h"
@@ -162,11 +162,18 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff)
       break;
 
     case DEVICE_CLOSE:
-
       #ifdef TEST
       fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_CLOSE].\n");
       #endif
 
+      for (int i = 0; i < pDev->nPrivates; i++)
+      {
+        free(pDev->devPrivates[i].ptr);
+        pDev->devPrivates[i].ptr = NULL;
+      }
+      free(pDev->devPrivates);
+      pDev->devPrivates = NULL;
+
       break;
     }
 

--
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