From cf1ebf2133fb162528c9d73e63115c86f2131aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 2 Jul 2025 13:33:57 +0200 Subject: [PATCH] Platform: ensure GLX configs are freed even in case of an error. I thought this would fix a leak reported by ASan when running on Mesa 25 llvmpipe, but it didn't. Given that no leak is reported when *not* running on llvmpipe, I assume this is llvmpipe's fault. --- src/Magnum/Platform/WindowlessGlxApplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Platform/WindowlessGlxApplication.cpp b/src/Magnum/Platform/WindowlessGlxApplication.cpp index c02b77dc4..9066ee7e5 100644 --- a/src/Magnum/Platform/WindowlessGlxApplication.cpp +++ b/src/Magnum/Platform/WindowlessGlxApplication.cpp @@ -27,6 +27,7 @@ #include "WindowlessGlxApplication.h" +#include #include #include #include @@ -100,6 +101,7 @@ WindowlessGlxContext::WindowlessGlxContext(const WindowlessGlxContext::Configura Error() << "Platform::WindowlessGlxContext: no supported framebuffer configuration found"; return; } + Containers::ScopeGuard freeConfigs{configs, XFree}; /* Create pbuffer */ constexpr static const int pbufferAttributes[] = { @@ -266,8 +268,6 @@ WindowlessGlxContext::WindowlessGlxContext(const WindowlessGlxContext::Configura static_cast(magnumContext); #endif - XFree(configs); - if(!_context) { Error e; e << "Platform::WindowlessGlxContext: cannot create context";