aboutsummaryrefslogtreecommitdiff
path: root/render/drm_format_set.c
diff options
context:
space:
mode:
authorAntonin Décimo <antonin.decimo@gmail.com>2019-08-09 14:59:42 +0200
committerDrew DeVault <sir@cmpwn.com>2019-08-12 09:37:21 +0900
commitc1be9b6945f9c664fe694a09620758db9ca695e9 (patch)
tree0f746280361ee6c3659f9c6f2d1d6315f87410e4 /render/drm_format_set.c
parent52037d13f7617bef8e0f2566cb4609646cf8cd8f (diff)
render/drm: keep old drm_format if realloc fails
Diffstat (limited to 'render/drm_format_set.c')
-rw-r--r--render/drm_format_set.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/render/drm_format_set.c b/render/drm_format_set.c
index b09a68a4..297c2ab1 100644
--- a/render/drm_format_set.c
+++ b/render/drm_format_set.c
@@ -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);
if (ptr) {
- struct wlr_drm_format *fmt = *ptr;
+ struct wlr_drm_format *fmt = *ptr, *newfmt = NULL;
if (modifier == DRM_FORMAT_MOD_INVALID) {
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) {
size_t cap = fmt->cap ? fmt->cap * 2 : 4;
- fmt = realloc(fmt, sizeof(*fmt) + sizeof(fmt->modifiers[0]) * cap);
- if (!fmt) {
+ newfmt = realloc(fmt, sizeof(*fmt) + sizeof(fmt->modifiers[0]) * cap);
+ if (!newfmt) {
wlr_log_errno(WLR_ERROR, "Allocation failed");
return false;
}
- fmt->cap = cap;
- *ptr = fmt;
+ newfmt->cap = cap;
+ *ptr = newfmt;
}
- fmt->modifiers[fmt->len++] = modifier;
+ newfmt->modifiers[newfmt->len++] = modifier;
return true;
}