[PATCH:libXxf86vm 2/4] Unlock display before returning alloc error in XF86VidModeGetModeLine()

Alan Coopersmith alan.coopersmith at oracle.com
Sat Apr 13 18:48:19 PDT 2013


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/XF86VMode.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/XF86VMode.c b/src/XF86VMode.c
index 165f8ba..28c79c1 100644
--- a/src/XF86VMode.c
+++ b/src/XF86VMode.c
@@ -203,6 +203,7 @@ XF86VidModeGetModeLine(Display* dpy, int screen, int* dotclock,
     xXF86OldVidModeGetModeLineReply oldrep;
     xXF86VidModeGetModeLineReq *req;
     int majorVersion, minorVersion;
+    Bool result = True;
 
     XF86VidModeCheckExtension (dpy, info, False);
     XF86VidModeQueryVersion(dpy, &majorVersion, &minorVersion);
@@ -254,17 +255,18 @@ XF86VidModeGetModeLine(Display* dpy, int screen, int* dotclock,
     }
 
     if (modeline->privsize > 0) {
-	if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) {
+	modeline->private = Xcalloc(modeline->privsize, sizeof(INT32));
+	if (modeline->private == NULL) {
 	    _XEatData(dpy, (modeline->privsize) * sizeof(INT32));
-	    return False;
-	}
-	_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
+	    result = False;
+	} else
+	    _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
     } else {
 	modeline->private = NULL;
     }
     UnlockDisplay(dpy);
     SyncHandle();
-    return True;
+    return result;
 }
 
 Bool
-- 
1.7.9.2



More information about the xorg-devel mailing list