xlib: handle _mesa_initialize_visual()'s return value
authorBrian Paul <brianp@vmware.com>
Wed, 26 Dec 2012 23:26:58 +0000 (16:26 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 1 Jan 2013 01:17:58 +0000 (18:17 -0700)
If the call fails, we should return NULL from XMesaCreateVisual().
This was found when Waffle tried to create a visual with depth/stencil
bits = -1.  That's an illegal value for glXChooseFBConfig() and we should
return NULL in that situation.

Note: This is a candidate for the stable branches.

src/mesa/drivers/x11/xm_api.c

index 8105f4dbd5267711d2ed279d1bab675c5afd4f4d..2ba65ffd787d5097319b0624bccdf47d4b17d9b2 100644 (file)
@@ -847,15 +847,18 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
       alpha_bits = v->mesa_visual.alphaBits;
    }
 
-   _mesa_initialize_visual( &v->mesa_visual,
-                            db_flag, stereo_flag,
-                            red_bits, green_bits,
-                            blue_bits, alpha_bits,
-                            depth_size,
-                            stencil_size,
-                            accum_red_size, accum_green_size,
-                            accum_blue_size, accum_alpha_size,
-                            0 );
+   if (!_mesa_initialize_visual(&v->mesa_visual,
+                                db_flag, stereo_flag,
+                                red_bits, green_bits,
+                                blue_bits, alpha_bits,
+                                depth_size,
+                                stencil_size,
+                                accum_red_size, accum_green_size,
+                                accum_blue_size, accum_alpha_size,
+                                0)) {
+      FREE(v);
+      return NULL;
+   }
 
    /* XXX minor hack */
    v->mesa_visual.level = level;