aboutsummaryrefslogtreecommitdiff
path: root/xcursor
diff options
context:
space:
mode:
authorKirill Primak <vyivel@eclair.cafe>2023-11-19 13:51:31 +0300
committerKirill Primak <vyivel@eclair.cafe>2023-11-19 15:33:39 +0300
commitc6b498528c48d44444e320536b3ba1faa37b1d83 (patch)
tree50ad18688432fe1e8ec883c710759cb453752ffa /xcursor
parente16b0068a70b6d2cf57177de197e9b171e39bb78 (diff)
xcursor: don't store NULL xcursors
Diffstat (limited to 'xcursor')
-rw-r--r--xcursor/wlr_xcursor.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/xcursor/wlr_xcursor.c b/xcursor/wlr_xcursor.c
index 6c6e11df..a946efdf 100644
--- a/xcursor/wlr_xcursor.c
+++ b/xcursor/wlr_xcursor.c
@@ -100,19 +100,19 @@ static void load_default_theme(struct wlr_xcursor_theme *theme) {
free(theme->name);
theme->name = strdup("default");
- theme->cursor_count = sizeof(cursor_metadata) / sizeof(cursor_metadata[0]);
- theme->cursors = malloc(theme->cursor_count * sizeof(*theme->cursors));
+ size_t cursor_count = sizeof(cursor_metadata) / sizeof(cursor_metadata[0]);
+ theme->cursor_count = 0;
+ theme->cursors = malloc(cursor_count * sizeof(*theme->cursors));
if (theme->cursors == NULL) {
- theme->cursor_count = 0;
return;
}
- for (uint32_t i = 0; i < theme->cursor_count; ++i) {
- theme->cursors[i] =
- xcursor_create_from_data(&cursor_metadata[i], theme);
+ for (uint32_t i = 0; i < cursor_count; ++i) {
+ theme->cursors[i] = xcursor_create_from_data(&cursor_metadata[i], theme);
if (theme->cursors[i] == NULL) {
break;
}
+ ++theme->cursor_count;
}
}