aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-12-05 00:29:10 +0100
committerMihai Moldovan <ionic@ionic.de>2017-12-07 08:33:44 +0100
commitcdaec755d8800d3cb78e3d7c65b4320c067e27cf (patch)
treeb5cf54e6114bbee8616a02d1cde662819a2b8679 /nx-X11
parent0938cf83d37407267e17a2620da8ce1fc8264be8 (diff)
downloadnx-libs-cdaec755d8800d3cb78e3d7c65b4320c067e27cf.tar.gz
nx-libs-cdaec755d8800d3cb78e3d7c65b4320c067e27cf.tar.bz2
nx-libs-cdaec755d8800d3cb78e3d7c65b4320c067e27cf.zip
Make sure XQueryTree results are freed
Fixes ArcticaProject/nx-libs#585
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Events.c32
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Rootless.c2
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Window.c12
3 files changed, 24 insertions, 22 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c
index e360d21f6..4e08cd2c2 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Events.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c
@@ -426,13 +426,12 @@ void nxagentRemoteWindowsTree(Window window, int level)
int i, j;
unsigned long rootWin, parentWin;
unsigned int numChildren;
- unsigned long *childList;
+ unsigned long *childList = NULL;
if (!XQueryTree(nxagentDisplay, window, &rootWin, &parentWin, &childList,
&numChildren))
{
fprintf(stderr, "nxagentRemoteWindowsTree - XQueryTree failed.\n");
-
return;
}
@@ -3185,7 +3184,7 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
#endif
}
- if (result && nchildren_return)
+ if (children_return)
{
XFree(children_return);
}
@@ -3540,6 +3539,12 @@ int nxagentHandleReparentNotify(XEvent* X)
result = XQueryTree(nxagentDisplay, w, &root_return,
&parent_return, &children_return, &nchildren_return);
+ if (children_return)
+ {
+ XFree(children_return);
+ children_return = NULL;
+ }
+
if (!result)
{
#ifdef WARNING
@@ -3548,11 +3553,6 @@ int nxagentHandleReparentNotify(XEvent* X)
break;
}
-
- if (result && children_return)
- {
- XFree(children_return);
- }
}
if (w && !nxagentWindowPtr(w))
@@ -3581,9 +3581,10 @@ int nxagentHandleReparentNotify(XEvent* X)
#endif
}
- if (result && nchildren_return)
+ if (children_return)
{
XFree(children_return);
+ children_return = NULL;
}
}
else
@@ -3647,17 +3648,18 @@ int nxagentHandleReparentNotify(XEvent* X)
{
result = XQueryTree(nxagentDisplay, w, &rootReturn, &parentReturn,
&childrenReturn, &nchildrenReturn);
-
- if (parentReturn == rootReturn || parentReturn == 0 || result == 0)
+
+ if (childrenReturn)
{
- break;
+ XFree(childrenReturn);
+ childrenReturn = NULL;
}
- if (result == 1 && childrenReturn != NULL)
+ if (parentReturn == rootReturn || parentReturn == 0 || result == 0)
{
- XFree(childrenReturn);
+ break;
}
-
+
w = parentReturn;
}
while (True);
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
index 364f0cbe4..437140f61 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c
@@ -249,7 +249,7 @@ Bool nxagentRootlessTreesMatch()
{
Window root_return;
Window parent_return;
- Window *children_return;
+ Window *children_return = NULL;
unsigned int nChildrenReturn;
WindowPtr pTestWin = screenInfo.screens[0]->root -> firstChild;
Bool treesMatch = True;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c
index 849317f25..1cad4ca03 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Window.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c
@@ -1454,7 +1454,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
{
Window root_return;
Window parent_return;
- Window *children_return;
+ Window *children_return = NULL;
unsigned int nchildren_return;
Status result;
@@ -1473,16 +1473,16 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
}
}
fprintf(stderr, "\n");
-
- if (children_return)
- {
- XFree(children_return);
- }
}
else
{
fprintf(stderr, "nxagentConfigureWindow: Failed QueryTree request.\n ");
}
+
+ if (children_return)
+ {
+ XFree(children_return);
+ }
}
#endif
}