From 820800a5aba9172c8639e97b4de0503b35eb9aa2 Mon Sep 17 00:00:00 2001 From: Antonin Décimo Date: Fri, 9 Aug 2019 16:48:33 +0200 Subject: xcursor: avoid leak and loss of all cursors if cursors realloc fails --- xcursor/wlr_xcursor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'xcursor') 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; } } -- cgit v1.2.3