mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
xcursor: avoid leak and loss of all cursors if cursors realloc fails
This commit is contained in:
parent
c1be9b6945
commit
820800a5ab
1 changed files with 4 additions and 2 deletions
|
@ -196,15 +196,17 @@ static void load_callback(XcursorImages *images, void *data) {
|
|||
cursor = xcursor_create_from_xcursor_images(images, theme);
|
||||
|
||||
if (cursor) {
|
||||
struct wlr_xcursor **cursors;
|
||||
theme->cursor_count++;
|
||||
theme->cursors =
|
||||
cursors =
|
||||
realloc(theme->cursors,
|
||||
theme->cursor_count * sizeof(theme->cursors[0]));
|
||||
|
||||
if (theme->cursors == NULL) {
|
||||
if (cursors == NULL) {
|
||||
theme->cursor_count--;
|
||||
free(cursor);
|
||||
} else {
|
||||
theme->cursors = cursors;
|
||||
theme->cursors[theme->cursor_count - 1] = cursor;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue