From 810796b390083161aed4edef91a1c6664057e505 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 15 Nov 2014 19:40:37 +0100 Subject: [PATCH] WMaker: Fixed crash if the RContext creation fail on a Screen (Coverity #50066) As pointed by Coverity, it is possible that RCreateContext fails for more reasons that were handled by wScreenInit, so we provide an error message for the other cases along with cleaner return from function. Signed-off-by: Christophe CURIS Signed-off-by: Carlos R. Mafra --- src/screen.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/screen.c b/src/screen.c index 36943fbd..51e23178 100644 --- a/src/screen.c +++ b/src/screen.c @@ -577,6 +577,11 @@ WScreen *wScreenInit(int screen_number) scr->rcontext = RCreateContext(dpy, screen_number, &rattr); } + if (scr->rcontext == NULL) { + wfatal(_("can't create Context on screen %d, %s"), + screen_number, RMessageForError(RErrorCode)); + goto abort_no_context; + } scr->w_win = scr->rcontext->drawable; scr->w_visual = scr->rcontext->visual; @@ -589,6 +594,7 @@ WScreen *wScreenInit(int screen_number) if (!scr->wmscreen) { wfatal(_("could not initialize WINGs widget set")); RDestroyContext(scr->rcontext); + abort_no_context: WMFreeArray(scr->fakeGroupLeaders); wfree(scr->totalUsableArea); wfree(scr->usableArea);