check return values of _swrast_CreateContext, etc
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 21 Apr 2004 16:11:27 +0000 (16:11 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 21 Apr 2004 16:11:27 +0000 (16:11 +0000)
src/mesa/drivers/osmesa/osmesa.c
src/mesa/drivers/x11/xm_api.c

index a8e6b12832d34a0fca4d98da36a63597cd828cbc..7932b90f59708b3b50d32f9d679aad6509e9471e 100644 (file)
@@ -980,10 +980,15 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
       {
         GLcontext *ctx = &osmesa->mesa;
 
-        _swrast_CreateContext( ctx );
-        _ac_CreateContext( ctx );
-        _tnl_CreateContext( ctx );
-        _swsetup_CreateContext( ctx );
+        if (!_swrast_CreateContext( ctx ) ||
+             !_ac_CreateContext( ctx ) ||
+             !_tnl_CreateContext( ctx ) ||
+             !_swsetup_CreateContext( ctx )) {
+            _mesa_destroy_visual(osmesa->gl_visual);
+            _mesa_free_context_data(ctx);
+            _mesa_free(osmesa);
+            return NULL;
+         }
        
         _swsetup_Wakeup( ctx );
          hook_in_driver_functions( ctx );
index da2371eb7cc0005e554e7b072b4663f5c904cb59..bdf6f1d42861090465ecaf2b4c1869c952161b9d 100644 (file)
@@ -1677,10 +1677,14 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
 
    /* Initialize the software rasterizer and helper modules.
     */
-   _swrast_CreateContext( mesaCtx );
-   _ac_CreateContext( mesaCtx );
-   _tnl_CreateContext( mesaCtx );
-   _swsetup_CreateContext( mesaCtx );
+   if (!_swrast_CreateContext( mesaCtx ) ||
+       !_ac_CreateContext( mesaCtx ) ||
+       !_tnl_CreateContext( mesaCtx ) ||
+       !_swsetup_CreateContext( mesaCtx )) {
+      _mesa_free_context_data(&c->mesa);
+      _mesa_free(c);
+      return NULL;
+   }
 
    /* tnl setup */
    tnl = TNL_CONTEXT(mesaCtx);