aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Anderson <ascent12@hotmail.com>2019-02-21 07:23:25 +0000
committerGitHub <noreply@github.com>2019-02-21 07:23:25 +0000
commit132290aeb442c15e5ea80a40fd12e7edae8965ca (patch)
treef80498a019aed9d1de8637f12a2fd96108e83dc5
parent18600f457be7a538e39914c37b72fee1a933ebe1 (diff)
parente1834ace280962fc57f3e086299c980e0e07067f (diff)
Merge pull request #1565 from Emantor/fix/realloc_allocation
backend/drm: fix memory leak in realloc crtcs
-rw-r--r--backend/drm/drm.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c
index a7719727..12ed61ef 100644
--- a/backend/drm/drm.c
+++ b/backend/drm/drm.c
@@ -888,8 +888,9 @@ static void dealloc_crtc(struct wlr_drm_connector *conn) {
static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
size_t num_outputs = wl_list_length(&drm->outputs);
+ bool changed_local = changed_outputs ? false : true;
- if (changed_outputs == NULL) {
+ if (changed_local) {
changed_outputs = calloc(num_outputs, sizeof(bool));
if (changed_outputs == NULL) {
wlr_log(WLR_ERROR, "Allocation failed");
@@ -952,7 +953,7 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
connectors[crtc[i]]->desired_enabled) {
wlr_log(WLR_DEBUG, "Could not match a CRTC for connected output %d",
crtc[i]);
- return;
+ goto free_changed_outputs;
}
}
@@ -1021,6 +1022,11 @@ static void realloc_crtcs(struct wlr_drm_backend *drm, bool *changed_outputs) {
wlr_output_damage_whole(&conn->output);
}
+
+free_changed_outputs:
+ if (changed_local) {
+ free(changed_outputs);
+ }
}
static uint32_t get_possible_crtcs(int fd, drmModeRes *res,