c/main: Don't use list of display if we fail to allocate it

This commit is contained in:
Jakob Bornecrantz 2024-01-07 12:25:05 +00:00 committed by Simon Zeni
parent 4a2eebdc69
commit 141046585d
3 changed files with 19 additions and 4 deletions

View file

@ -177,8 +177,13 @@ append_nvidia_entry_on_match(struct comp_window_direct_nvidia *w,
U_ARRAY_REALLOC_OR_FREE(w->displays, struct comp_window_direct_nvidia_display, w->display_count);
if (w->displays == NULL)
COMP_ERROR(w->base.base.c, "Unable to reallocate randr_displays");
if (w->displays == NULL) {
COMP_ERROR(w->base.base.c, "Unable to reallocate NVIDIA displays");
// Reset the count.
w->display_count = 0;
return false;
}
w->displays[w->display_count - 1] = d;

View file

@ -345,9 +345,14 @@ append_randr_display(struct comp_window_direct_randr *w,
U_ARRAY_REALLOC_OR_FREE(w->displays, struct comp_window_direct_randr_display, w->display_count);
if (w->displays == NULL)
if (w->displays == NULL) {
COMP_ERROR(w->base.base.c, "Unable to reallocate randr_displays");
// Reset the count.
w->display_count = 0;
return;
}
w->displays[w->display_count - 1] = d;
}

View file

@ -141,9 +141,14 @@ append_vk_display_entry(struct comp_window_vk_display *w, struct VkDisplayProper
U_ARRAY_REALLOC_OR_FREE(w->displays, struct vk_display, w->display_count);
if (w->displays == NULL)
if (w->displays == NULL) {
COMP_ERROR(w->base.base.c, "Unable to reallocate vk_display displays");
// Reset the count.
w->display_count = 0;
return false;
}
w->displays[w->display_count - 1] = d;
return true;