mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
X11: Fix potential window property data leaks
This commit is contained in:
parent
fa21cd13d2
commit
0735250eb1
@ -381,13 +381,11 @@ static void detectEWMH(void)
|
|||||||
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
|
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
|
||||||
|
|
||||||
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
|
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
|
||||||
if (_glfwGetWindowPropertyX11(_glfw.x11.root,
|
if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
|
||||||
supportingWmCheck,
|
supportingWmCheck,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromRoot) != 1)
|
(unsigned char**) &windowFromRoot))
|
||||||
{
|
{
|
||||||
if (windowFromRoot)
|
|
||||||
XFree(windowFromRoot);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,14 +393,12 @@ static void detectEWMH(void)
|
|||||||
|
|
||||||
// It should be the ID of a child window (of the root)
|
// It should be the ID of a child window (of the root)
|
||||||
// Then we look for the same property on the child window
|
// Then we look for the same property on the child window
|
||||||
if (_glfwGetWindowPropertyX11(*windowFromRoot,
|
if (!_glfwGetWindowPropertyX11(*windowFromRoot,
|
||||||
supportingWmCheck,
|
supportingWmCheck,
|
||||||
XA_WINDOW,
|
XA_WINDOW,
|
||||||
(unsigned char**) &windowFromChild) != 1)
|
(unsigned char**) &windowFromChild))
|
||||||
{
|
{
|
||||||
XFree(windowFromRoot);
|
XFree(windowFromRoot);
|
||||||
if (windowFromChild)
|
|
||||||
XFree(windowFromChild);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +451,8 @@ static void detectEWMH(void)
|
|||||||
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
|
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
|
||||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
|
getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
|
||||||
|
|
||||||
XFree(supportedAtoms);
|
if (supportedAtoms)
|
||||||
|
XFree(supportedAtoms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize X11 display and look for supported X11 extensions
|
// Initialize X11 display and look for supported X11 extensions
|
||||||
|
@ -130,7 +130,9 @@ static int getWindowState(_GLFWwindow* window)
|
|||||||
result = state->state;
|
result = state->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(state);
|
if (state)
|
||||||
|
XFree(state);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1324,7 +1326,8 @@ static void processEvent(XEvent *event)
|
|||||||
free(paths);
|
free(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(data);
|
if (data)
|
||||||
|
XFree(data);
|
||||||
|
|
||||||
XEvent reply;
|
XEvent reply;
|
||||||
memset(&reply, 0, sizeof(reply));
|
memset(&reply, 0, sizeof(reply));
|
||||||
@ -1481,9 +1484,6 @@ unsigned long _glfwGetWindowPropertyX11(Window window,
|
|||||||
&bytesAfter,
|
&bytesAfter,
|
||||||
value);
|
value);
|
||||||
|
|
||||||
if (type != AnyPropertyType && actualType != type)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return itemCount;
|
return itemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2042,7 +2042,9 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(states);
|
if (states)
|
||||||
|
XFree(states);
|
||||||
|
|
||||||
return maximized;
|
return maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2107,6 +2109,8 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
|||||||
_glfw.x11.NET_WM_STATE,
|
_glfw.x11.NET_WM_STATE,
|
||||||
XA_ATOM,
|
XA_ATOM,
|
||||||
(unsigned char**) &states);
|
(unsigned char**) &states);
|
||||||
|
if (!states)
|
||||||
|
return;
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
@ -2396,7 +2400,8 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
|||||||
_glfw.x11.clipboardString = strdup(data);
|
_glfw.x11.clipboardString = strdup(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(data);
|
if (data)
|
||||||
|
XFree(data);
|
||||||
|
|
||||||
XDeleteProperty(_glfw.x11.display,
|
XDeleteProperty(_glfw.x11.display,
|
||||||
event.xselection.requestor,
|
event.xselection.requestor,
|
||||||
|
Loading…
Reference in New Issue
Block a user