From 29da97c185c60eae5d9eaf743c3895c4dba139f7 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 8 Dec 2020 16:02:44 +0100 Subject: [PATCH] render/drm_format_set: allocate using cap when duplicating In wlr_drm_format_dup, allocate the new wlr_drm_format using cap instead of len. This makes it so the cap field is up-to-date and the chunk of memory isn't too small if we append new modifiers (we don't allow this yet but might in the future). --- render/drm_format_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/render/drm_format_set.c b/render/drm_format_set.c index d6be706d3..b3e8648ec 100644 --- a/render/drm_format_set.c +++ b/render/drm_format_set.c @@ -129,7 +129,7 @@ bool wlr_drm_format_set_add(struct wlr_drm_format_set *set, uint32_t format, struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format) { size_t format_size = sizeof(struct wlr_drm_format) + - format->len * sizeof(format->modifiers[0]); + format->cap * sizeof(format->modifiers[0]); struct wlr_drm_format *duped_format = malloc(format_size); if (duped_format == NULL) { return NULL;