diff options
author | Antonin Décimo <antonin.decimo@gmail.com> | 2019-08-09 16:48:33 +0200 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-08-12 09:37:21 +0900 |
commit | 820800a5aba9172c8639e97b4de0503b35eb9aa2 (patch) | |
tree | 8e401f383659189e4f8d0ee74632c072aa65b9c4 | |
parent | c1be9b6945f9c664fe694a09620758db9ca695e9 (diff) |
xcursor: avoid leak and loss of all cursors if cursors realloc fails
-rw-r--r-- | xcursor/wlr_xcursor.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/xcursor/wlr_xcursor.c b/xcursor/wlr_xcursor.c index d651497b..4e1d02ec 100644 --- a/xcursor/wlr_xcursor.c +++ b/xcursor/wlr_xcursor.c @@ -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; } } |