cursor: Free theme when size check fails to avoid memory leak

Signed-off-by: YaoBing Xiao <xiaoyaobing@uniontech.com>
This commit is contained in:
YaoBing Xiao 2025-07-16 22:29:40 +08:00 committed by Simon Ser
parent cd0d1543c0
commit 264da6a92b

View file

@ -398,7 +398,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
return NULL; return NULL;
if (size < 0 || (size > 0 && INT_MAX / size / 4 < size)) if (size < 0 || (size > 0 && INT_MAX / size / 4 < size))
return NULL; goto err;
if (!name) if (!name)
name = "default"; name = "default";
@ -409,7 +409,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
theme->pool = shm_pool_create(shm, size * size * 4); theme->pool = shm_pool_create(shm, size * size * 4);
if (!theme->pool) if (!theme->pool)
goto out_error_pool; goto err;
xcursor_load_theme(name, size, load_callback, theme); xcursor_load_theme(name, size, load_callback, theme);
@ -421,7 +421,7 @@ wl_cursor_theme_load(const char *name, int size, struct wl_shm *shm)
return theme; return theme;
out_error_pool: err:
free(theme); free(theme);
return NULL; return NULL;
} }