mirror of
				https://github.com/glfw/glfw.git
				synced 2025-11-04 06:15:07 +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,6 +451,7 @@ 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");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (supportedAtoms)
 | 
				
			||||||
        XFree(supportedAtoms);
 | 
					        XFree(supportedAtoms);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -130,7 +130,9 @@ static int getWindowState(_GLFWwindow* window)
 | 
				
			|||||||
        result = state->state;
 | 
					        result = state->state;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (state)
 | 
				
			||||||
        XFree(state);
 | 
					        XFree(state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1324,6 +1326,7 @@ static void processEvent(XEvent *event)
 | 
				
			|||||||
                    free(paths);
 | 
					                    free(paths);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (data)
 | 
				
			||||||
                    XFree(data);
 | 
					                    XFree(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                XEvent reply;
 | 
					                XEvent 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)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (states)
 | 
				
			||||||
        XFree(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,6 +2400,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
 | 
				
			|||||||
            _glfw.x11.clipboardString = strdup(data);
 | 
					            _glfw.x11.clipboardString = strdup(data);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (data)
 | 
				
			||||||
            XFree(data);
 | 
					            XFree(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        XDeleteProperty(_glfw.x11.display,
 | 
					        XDeleteProperty(_glfw.x11.display,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user