From 626e419972ca21a41dd4a7d26b3d1c3d4368a246 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 24 Jan 2026 13:23:00 +0100 Subject: [PATCH] x11: Fix various very minor memory leaks --- panda/src/glxdisplay/glxGraphicsStateGuardian.cxx | 5 +++++ panda/src/x11display/x11GraphicsWindow.cxx | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index 83ea5f2b2f..be8c5f7f10 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -402,6 +402,7 @@ choose_pixel_format(const FrameBufferProperties &properties, << ", context_has_pixmap = " << _context_has_pixmap << "\n"; } + XFree(configs); return; } } @@ -414,6 +415,10 @@ choose_pixel_format(const FrameBufferProperties &properties, _visuals = nullptr; } + if (configs != nullptr) { + XFree(configs); + } + glxdisplay_cat.warning() << "No suitable FBConfig contexts available; using XVisual only.\n" << _fbprops << "\n"; diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 90d1ee0d44..b3363ff110 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -634,10 +634,10 @@ process_events() { Atom type; int format; unsigned long nItem, bytesAfter; - unsigned char *new_window_properties = NULL; + unsigned char *new_window_properties = nullptr; // gather all properties from the active dispplay and window XGetWindowProperty(_display, _xwindow, wmState, 0, LONG_MAX, false, AnyPropertyType, &type, &format, &nItem, &bytesAfter, &new_window_properties); - if (nItem > 0) { + if (nItem > 0 && new_window_properties != nullptr) { x11GraphicsPipe *x11_pipe; DCAST_INTO_V(x11_pipe, _pipe); // run through all found items @@ -650,6 +650,7 @@ process_events() { is_maximized = true; } } + XFree(new_window_properties); } // Debug entry @@ -1532,6 +1533,9 @@ set_wm_properties(const WindowProperties &properties, bool already_mapped) { XSetWMProperties(_display, _xwindow, window_name_p, window_name_p, nullptr, 0, size_hints_p, wm_hints_p, class_hints_p); + if (window_name_p != nullptr) { + XFree(window_name.value); + } if (size_hints_p != nullptr) { XFree(size_hints_p); }