Fix potential NPE if user doesn't register display
[glsdk/libdri2.git] / 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();