Fix potential NPE if user doesn't register display
authorRob Clark <rob.clark@linaro.org>
Fri, 8 Jun 2012 19:46:11 +0000 (14:46 -0500)
committerNikhil Devshatwar <a0132237@ti.com>
Thu, 16 May 2013 14:10:21 +0000 (19:40 +0530)
src/dri2.c

index e08caefe1fd7dace80b174970facb10d151e3105..65cd497204b63eae68fa49d5fd9ce8e5bd636418 100644 (file)
@@ -218,8 +218,15 @@ DRI2QueryVersion(Display * dpy, int *major, int *minor)
       SyncHandle();
       return False;
    }
-   dri2dpy->major = *major = rep.majorVersion;
-   dri2dpy->minor = *minor = rep.minorVersion;
+
+   *major = rep.majorVersion;
+   *minor = rep.minorVersion;
+
+   if (dri2dpy) {
+          dri2dpy->major = rep.majorVersion;
+          dri2dpy->minor = rep.minorVersion;
+   }
+
    UnlockDisplay(dpy);
    SyncHandle();