Skip to content

Commit

Permalink
Fixed memory leak in xdpy_set_system_mouse_cursor()
Browse files Browse the repository at this point in the history
  • Loading branch information
Helodity authored and SiegeLord committed Dec 28, 2024
1 parent da53331 commit 4048fe0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/x/xcursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4048fe0

Please sign in to comment.