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).
This commit is contained in:
Simon Ser 2020-12-08 16:02:44 +01:00
parent e69bbfd0d6
commit 29da97c185
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 1 additions and 1 deletions

View File

@ -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;