From: Matthias Clasen Date: Thu, 1 Jun 2023 00:34:28 +0000 (-0400) Subject: wayland: Don't leak cursor structs X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~186^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=85bafbdff07195b2c4234ff05ce32b189a67f158;p=gtk4.git wayland: Don't leak cursor structs Found by gcc's -fanalyzer. --- diff --git a/gdk/wayland/cursor/wayland-cursor.c b/gdk/wayland/cursor/wayland-cursor.c index 4be8f9a4d4..957a577ab7 100644 --- a/gdk/wayland/cursor/wayland-cursor.c +++ b/gdk/wayland/cursor/wayland-cursor.c @@ -207,7 +207,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme, { char *path; XcursorImages *images; - struct cursor *cursor; + struct wl_cursor *cursor; struct cursor_image *image; int i, nbytes; unsigned int load_size; @@ -240,17 +240,16 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme, return NULL; } - cursor->cursor.images = - malloc(images->nimage * sizeof cursor->cursor.images[0]); - if (!cursor->cursor.images) { + cursor->images = + malloc(images->nimage * sizeof cursor->images[0]); + if (!cursor->images) { free(cursor); xcursor_images_destroy (images); return NULL; } - cursor->cursor.name = strdup(name); - cursor->cursor.size = load_size; - cursor->total_delay = 0; + cursor->name = strdup(name); + cursor->size = load_size; for (i = 0; i < images->nimage; i++) { image = malloc(sizeof *image); @@ -291,14 +290,13 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme, } } } - cursor->total_delay += image->image.delay; - cursor->cursor.images[i] = (struct wl_cursor_image *) image; + cursor->images[i] = (struct wl_cursor_image *) image; } - cursor->cursor.image_count = i; + cursor->image_count = i; - if (cursor->cursor.image_count == 0) { - free(cursor->cursor.name); - free(cursor->cursor.images); + if (cursor->image_count == 0) { + free(cursor->name); + free(cursor->images); free(cursor); xcursor_images_destroy (images); return NULL; @@ -306,7 +304,7 @@ wl_cursor_create_from_xcursor_images(struct wl_cursor_theme *theme, xcursor_images_destroy (images); - return &cursor->cursor; + return cursor; } static void