diff --git a/src/wayland-util.c b/src/wayland-util.c index c89a67bd..68116bf9 100644 --- a/src/wayland-util.c +++ b/src/wayland-util.c @@ -241,8 +241,10 @@ wl_map_insert_at(struct wl_map *map, uint32_t flags, uint32_t i, void *data) if (count < i) return -1; - if (count == i) - wl_array_add(entries, sizeof *start); + if (count == i) { + if (!wl_array_add(entries, sizeof *start)) + return -1; + } start = entries->data; start[i].data = data; @@ -277,7 +279,9 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i) return -1; if (count == i) { - wl_array_add(entries, sizeof *start); + if (!wl_array_add(entries, sizeof *start)) + return -1; + start = entries->data; start[i].data = NULL; } else {