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).
master
Simon Ser 4 years ago
parent e69bbfd0d6
commit 29da97c185
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -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) { struct wlr_drm_format *wlr_drm_format_dup(const struct wlr_drm_format *format) {
size_t format_size = sizeof(struct wlr_drm_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); struct wlr_drm_format *duped_format = malloc(format_size);
if (duped_format == NULL) { if (duped_format == NULL) {
return NULL; return NULL;

Loading…
Cancel
Save