Unverified Commit eb961873 authored by Mihai Moldovan's avatar Mihai Moldovan

Merge branch 'uli42-p/xquerytree_leak' into 3.6.x

Attributes GH PR #588: https://github.com/ArcticaProject/nx-libs/pull/588 Fixes: ArcticaProject/nx-libs#585
parents 5487d52f ad53af09
......@@ -417,6 +417,8 @@ void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine)
}
}
#ifdef DEBUG_TREE
/*
* Walk remote windows tree.
*/
......@@ -426,13 +428,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;
}
......@@ -481,6 +482,7 @@ void nxagentRemoteWindowsTree(Window window, int level)
XFree((char *) childList);
}
}
#endif
/*
* Print info about internal window.
......@@ -3185,7 +3187,7 @@ int nxagentCheckWindowConfiguration(XConfigureEvent* X)
#endif
}
if (result && nchildren_return)
if (children_return)
{
XFree(children_return);
}
......@@ -3540,6 +3542,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 +3556,6 @@ int nxagentHandleReparentNotify(XEvent* X)
break;
}
if (result && children_return)
{
XFree(children_return);
}
}
if (w && !nxagentWindowPtr(w))
......@@ -3581,9 +3584,10 @@ int nxagentHandleReparentNotify(XEvent* X)
#endif
}
if (result && nchildren_return)
if (children_return)
{
XFree(children_return);
children_return = NULL;
}
}
else
......@@ -3648,14 +3652,15 @@ 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;
......
......@@ -249,9 +249,8 @@ Bool nxagentRootlessTreesMatch()
{
Window root_return;
Window parent_return;
Window *children_return;
Window *children_return = NULL;
unsigned int nChildrenReturn;
WindowPtr pW;
WindowPtr pTestWin = screenInfo.screens[0]->root -> firstChild;
Bool treesMatch = True;
Status result;
......@@ -270,7 +269,7 @@ Bool nxagentRootlessTreesMatch()
while (nChildrenReturn > 0)
{
pW = nxagentWindowPtr(children_return[--nChildrenReturn]);
WindowPtr pW = nxagentWindowPtr(children_return[--nChildrenReturn]);
if (!pW)
{
......
......@@ -1454,9 +1454,8 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
{
Window root_return;
Window parent_return;
Window *children_return;
Window *children_return = NULL;
unsigned int nchildren_return;
Window *pw;
Status result;
result = XQueryTree(nxagentDisplay, DefaultRootWindow(nxagentDisplay),
......@@ -1464,8 +1463,6 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask)
if (result)
{
pw = children_return;
fprintf(stderr, "nxagentConfigureWindow: Children of the root: ");
while(nchildren_return > 0)
{
......@@ -1476,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
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment