[PATCH 2/4] compositor-drm: Fix memory leak in create_output_for_connector

David Herrmann dh.herrmann at googlemail.com
Thu Dec 8 08:05:44 PST 2011


We do not free the encoder structure on failure. Fix that.

Signed-off-by: David Herrmann <dh.herrmann at googlemail.com>
---
 compositor/compositor-drm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/compositor/compositor-drm.c b/compositor/compositor-drm.c
index 9f76187..1f5e028 100644
--- a/compositor/compositor-drm.c
+++ b/compositor/compositor-drm.c
@@ -445,12 +445,15 @@ create_output_for_connector(struct drm_compositor *ec,
 	}
 	if (i == resources->count_crtcs) {
 		fprintf(stderr, "No usable crtc for encoder.\n");
+		drmModeFreeEncoder(encoder);
 		return -1;
 	}
 
 	output = malloc(sizeof *output);
-	if (output == NULL)
+	if (output == NULL) {
+		drmModeFreeEncoder(encoder);
 		return -1;
+	}
 
 	memset(output, 0, sizeof *output);
 	output->base.subpixel = drm_subpixel_to_wayland(connector->subpixel);
-- 
1.7.8



More information about the wayland-devel mailing list