From d0355b28dd53fba6fb29c350e090ed4a73d4c480 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 13 Apr 2013 17:58:28 -0700 Subject: Unlock display before returning alloc error in XF86VidModeGetDotClocks() Signed-off-by: Alan Coopersmith Reviewed-by: Peter Hutterer --- src/XF86VMode.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/XF86VMode.c b/src/XF86VMode.c index 76276b6..1b907f4 100644 --- a/src/XF86VMode.c +++ b/src/XF86VMode.c @@ -1014,6 +1014,7 @@ XF86VidModeGetDotClocks(Display* dpy, int screen, int *flagsPtr, xXF86VidModeGetDotClocksReq *req; int i, *dotclocks; CARD32 dotclk; + Bool result = True; XF86VidModeCheckExtension (dpy, info, False); @@ -1033,19 +1034,21 @@ XF86VidModeGetDotClocks(Display* dpy, int screen, int *flagsPtr, *maxclocksPtr = rep.maxclocks; *flagsPtr = rep.flags; - if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) { + dotclocks = Xcalloc(rep.clocks, sizeof(int)); + if (dotclocks == NULL) { _XEatData(dpy, (rep.clocks) * 4); - return False; + result = False; } - - for (i = 0; i < rep.clocks; i++) { - _XRead(dpy, (char*)&dotclk, 4); - dotclocks[i] = dotclk; + else { + for (i = 0; i < rep.clocks; i++) { + _XRead(dpy, (char*)&dotclk, 4); + dotclocks[i] = dotclk; + } } *clocksPtr = dotclocks; UnlockDisplay(dpy); SyncHandle(); - return True; + return result; } Bool -- cgit v1.2.3