summaryrefslogtreecommitdiffstats
path: root/main/libxxf86vm/0005-Unlock-display-before-returning-alloc-error-in-XF86V.patch
blob: b59be7bc1a9e8637fc55125775ee4fe26717acd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From d0355b28dd53fba6fb29c350e090ed4a73d4c480 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat, 13 Apr 2013 17:58:28 -0700
Subject: [PATCH 5/8] Unlock display before returning alloc error in
 XF86VidModeGetDotClocks()

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
---
 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
-- 
1.8.2.3