From b14228fafb654fe7d8f8783475aa0c0ba87e4fea Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 19 Nov 2013 12:15:24 +0000 Subject: [PATCH] intel-virtual-output: Check for failure to create a clone Signed-off-by: Chris Wilson --- tools/virtual.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/virtual.c b/tools/virtual.c index ab4f12b..2d5a4e4 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -2005,6 +2005,9 @@ static int last_display_add_clones__randr(struct context *ctx) struct clone *clone = add_clone(ctx); RROutput id; + if (clone == NULL) + return -ENOMEM; + clone->depth = 24; clone->next = display->clone; display->clone = clone; @@ -2073,6 +2076,9 @@ static int last_display_add_clones__xinerama(struct context *ctx) struct clone *clone = add_clone(ctx); RROutput id; + if (clone == NULL) + return -ENOMEM; + if (xi[n].width == 0 || xi[n].height == 0) continue; @@ -2130,14 +2136,18 @@ static int last_display_add_clones__xinerama(struct context *ctx) static int last_display_add_clones__display(struct context *ctx) { struct display *display = last_display(ctx); - struct clone *clone = add_clone(ctx); Display *dpy = display->dpy; + struct clone *clone; Screen *scr; char buf[80]; int ret; RROutput id; - DBG(("%s(%s)\n", __func__, DisplayString(display->dpy))); + + DBG(("%s(%s)\n", __func__, DisplayString(dpy))); + clone = add_clone(ctx); + if (clone == NULL) + return -ENOMEM; clone->depth = 24; clone->next = display->clone; @@ -2166,7 +2176,7 @@ static int last_display_add_clones__display(struct context *ctx) ret = clone_init_depth(clone); if (ret) { fprintf(stderr, "Failed to negotiate image format for display \"%s\"\n", - DisplayString(display->dpy)); + DisplayString(dpy)); return ret; } @@ -2180,7 +2190,7 @@ static int last_display_add_clones__display(struct context *ctx) ret = clone_update_modes__fixed(clone); if (ret) { fprintf(stderr, "Failed to clone display \"%s\"\n", - DisplayString(display->dpy)); + DisplayString(dpy)); return ret; } -- 2.7.4