i830: Validate API and version before calling i830CreateContext
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 7 Aug 2012 19:16:35 +0000 (12:16 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 14 Aug 2012 00:23:48 +0000 (17:23 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/intel/intel_screen.c

index cdae702adf5a0f68a09273a3052dc6f0ad4f38c8..877d11b709e23c33590f998355e977a548f24557 100644 (file)
@@ -736,9 +736,27 @@ intelCreateContext(gl_api api,
       success = i915CreateContext(api, mesaVis, driContextPriv,
                                   sharedContextPrivate);
    } else {
+      switch (api) {
+      case API_OPENGL:
+         if (major_version > 1 || minor_version > 3) {
+            *error = __DRI_CTX_ERROR_BAD_VERSION;
+            return false;
+         }
+         break;
+      case API_OPENGLES:
+         break;
+      default:
+         *error = __DRI_CTX_ERROR_BAD_API;
+         return false;
+      }
+
       intelScreen->no_vbo = true;
       success = i830CreateContext(mesaVis, driContextPriv,
                                  sharedContextPrivate);
+      if (!success) {
+         *error = __DRI_CTX_ERROR_NO_MEMORY;
+         return false;
+      }
    }
 #else
    success = brwCreateContext(api, mesaVis,