mesa: check default buffer object creation was successful
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 26 Jul 2017 01:11:01 +0000 (11:11 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 8 Aug 2017 05:56:12 +0000 (15:56 +1000)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/mesa/main/shared.c

index a2f0f8d398c40ad436a92ad8d1cf08724b9ee226..53b8597d560928c8b4fd6c58d651bfb3d981e93e 100644 (file)
@@ -44,6 +44,9 @@
 #include "util/hash_table.h"
 #include "util/set.h"
 
+static void
+free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared);
+
 /**
  * Allocate and initialize a shared context state structure.
  * Initializes the display list, texture objects and vertex programs hash
@@ -90,6 +93,8 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
 
    /* Allocate the default buffer object */
    shared->NullBufferObj = ctx->Driver.NewBufferObject(ctx, 0);
+   if (!shared->NullBufferObj)
+      goto fail;
 
    /* Create default texture objects */
    for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
@@ -132,6 +137,10 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
 
    shared->MemoryObjects = _mesa_NewHashTable();
    return shared;
+
+fail:
+   free_shared_state(ctx, shared);
+   return NULL;
 }