From 4048fe06d8401f2395f58ed4a19dd0f4dec0c167 Mon Sep 17 00:00:00 2001 From: Helodity Date: Sun, 22 Dec 2024 21:58:58 -0500 Subject: [PATCH] Fixed memory leak in xdpy_set_system_mouse_cursor() --- src/x/xcursor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/x/xcursor.c b/src/x/xcursor.c index a2f4457a1..b1689cb1e 100644 --- a/src/x/xcursor.c +++ b/src/x/xcursor.c @@ -123,14 +123,18 @@ static bool xdpy_set_mouse_cursor(ALLEGRO_DISPLAY *display, Display *xdisplay = system->x11display; Window xwindow = glx->window; + _al_mutex_lock(&system->lock); + if (glx->is_system_cursor && glx->current_cursor) { + XFreeCursor(xdisplay, glx->current_cursor); + } + glx->current_cursor = xcursor->cursor; glx->is_system_cursor = false; if (!glx->cursor_hidden) { - _al_mutex_lock(&system->lock); XDefineCursor(xdisplay, xwindow, glx->current_cursor); - _al_mutex_unlock(&system->lock); } + _al_mutex_unlock(&system->lock); return true; }