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);
|
||||
|
||||
// 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,
|
||||
XA_WINDOW,
|
||||
(unsigned char**) &windowFromRoot) != 1)
|
||||
(unsigned char**) &windowFromRoot))
|
||||
{
|
||||
if (windowFromRoot)
|
||||
XFree(windowFromRoot);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -395,14 +393,12 @@ static void detectEWMH(void)
|
||||
|
||||
// It should be the ID of a child window (of the root)
|
||||
// Then we look for the same property on the child window
|
||||
if (_glfwGetWindowPropertyX11(*windowFromRoot,
|
||||
if (!_glfwGetWindowPropertyX11(*windowFromRoot,
|
||||
supportingWmCheck,
|
||||
XA_WINDOW,
|
||||
(unsigned char**) &windowFromChild) != 1)
|
||||
(unsigned char**) &windowFromChild))
|
||||
{
|
||||
XFree(windowFromRoot);
|
||||
if (windowFromChild)
|
||||
XFree(windowFromChild);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -455,6 +451,7 @@ static void detectEWMH(void)
|
||||
_glfw.x11.NET_REQUEST_FRAME_EXTENTS =
|
||||
getSupportedAtom(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
|
||||
|
||||
if (supportedAtoms)
|
||||
XFree(supportedAtoms);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,9 @@ static int getWindowState(_GLFWwindow* window)
|
||||
result = state->state;
|
||||
}
|
||||
|
||||
if (state)
|
||||
XFree(state);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1324,6 +1326,7 @@ static void processEvent(XEvent *event)
|
||||
free(paths);
|
||||
}
|
||||
|
||||
if (data)
|
||||
XFree(data);
|
||||
|
||||
XEvent reply;
|
||||
@ -1481,9 +1484,6 @@ unsigned long _glfwGetWindowPropertyX11(Window window,
|
||||
&bytesAfter,
|
||||
value);
|
||||
|
||||
if (type != AnyPropertyType && actualType != type)
|
||||
return 0;
|
||||
|
||||
return itemCount;
|
||||
}
|
||||
|
||||
@ -2042,7 +2042,9 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
||||
}
|
||||
}
|
||||
|
||||
if (states)
|
||||
XFree(states);
|
||||
|
||||
return maximized;
|
||||
}
|
||||
|
||||
@ -2107,6 +2109,8 @@ void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
|
||||
_glfw.x11.NET_WM_STATE,
|
||||
XA_ATOM,
|
||||
(unsigned char**) &states);
|
||||
if (!states)
|
||||
return;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
@ -2396,6 +2400,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
||||
_glfw.x11.clipboardString = strdup(data);
|
||||
}
|
||||
|
||||
if (data)
|
||||
XFree(data);
|
||||
|
||||
XDeleteProperty(_glfw.x11.display,
|
||||
|
Loading…
Reference in New Issue
Block a user