wayland-cursor: fix to recreate to shm pool when it's not enough to contain a new...
authorSung-Jin Park <sj76.park@samsung.com>
Wed, 5 Apr 2017 08:02:22 +0000 (17:02 +0900)
committerJunkyeong Kim <jk0430.kim@samsung.com>
Thu, 16 Feb 2023 10:00:26 +0000 (19:00 +0900)
Change-Id: I9028c891ecbcabdb815c070ca414124f2206e392
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
cursor/wayland-cursor.c

index 2b7603d..bd0f482 100644 (file)
@@ -315,6 +315,15 @@ wl_cursor_create_from_xcursor_images(struct xcursor_images *images,
                image->image.delay = images->images[i]->delay;
 
                size = image->image.width * image->image.height * 4;
+               if ((theme->pool->used + size) > theme->pool->size) {
+                       shm_pool_destroy(theme->pool);
+                       theme->pool = shm_pool_create(theme->shm, 2 * theme->pool->size + size);
+                       if (!theme->pool) {
+                               free(image);
+                               break;
+                       }
+               }
+
                image->offset = shm_pool_allocate(theme->pool, size);
                if (image->offset < 0) {
                        free(image);
@@ -449,6 +458,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
        theme->size = size;
        theme->cursor_count = 0;
        theme->cursors = NULL;
+       theme->shm = shm;
 
        theme->pool = shm_pool_create(shm, size * size * 4);
        if (!theme->pool)