mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-23 05:15:58 +01:00
render/drm: keep old drm_format if realloc fails
This commit is contained in:
parent
52037d13f7
commit
c1be9b6945
1 changed files with 6 additions and 6 deletions
|
@ -60,7 +60,7 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
|
||||||
struct wlr_drm_format **ptr = format_set_get_ref(set, format);
|
struct wlr_drm_format **ptr = format_set_get_ref(set, format);
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
struct wlr_drm_format *fmt = *ptr;
|
struct wlr_drm_format *fmt = *ptr, *newfmt = NULL;
|
||||||
|
|
||||||
if (modifier == DRM_FORMAT_MOD_INVALID) {
|
if (modifier == DRM_FORMAT_MOD_INVALID) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -75,17 +75,17 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format,
|
||||||
if (fmt->len == fmt->cap) {
|
if (fmt->len == fmt->cap) {
|
||||||
size_t cap = fmt->cap ? fmt->cap * 2 : 4;
|
size_t cap = fmt->cap ? fmt->cap * 2 : 4;
|
||||||
|
|
||||||
fmt = realloc(fmt, sizeof(*fmt) + sizeof(fmt->modifiers[0]) * cap);
|
newfmt = realloc(fmt, sizeof(*fmt) + sizeof(fmt->modifiers[0]) * cap);
|
||||||
if (!fmt) {
|
if (!newfmt) {
|
||||||
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
wlr_log_errno(WLR_ERROR, "Allocation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt->cap = cap;
|
newfmt->cap = cap;
|
||||||
*ptr = fmt;
|
*ptr = newfmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt->modifiers[fmt->len++] = modifier;
|
newfmt->modifiers[newfmt->len++] = modifier;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue