[Mesa-dev] [PATCH 09/14] i830: Validate API and version before calling i830CreateContext

Ian Romanick idr at freedesktop.org
Wed Aug 8 10:38:17 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/drivers/dri/intel/intel_screen.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 54ad112..2fef8fe 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -723,9 +723,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,
-- 
1.7.6.5



More information about the mesa-dev mailing list