mesa: return GL_OUT_OF_MEMORY if NewSamplerObject fails
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Jul 2017 12:42:06 +0000 (14:42 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 24 Jul 2017 14:43:38 +0000 (16:43 +0200)
This is similar to other functions that create objects.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/main/samplerobj.c

index 326eceb1aa258a9f1a689fcaf1b7460a950fd828..7446441086203d8b45881b953913bf1669df45bd 100644 (file)
@@ -169,10 +169,18 @@ create_samplers(struct gl_context *ctx, GLsizei count, GLuint *samplers,
 
    /* Insert the ID and pointer to new sampler object into hash table */
    for (i = 0; i < count; i++) {
-      struct gl_sampler_object *sampObj =
-         ctx->Driver.NewSamplerObject(ctx, first + i);
-      _mesa_HashInsertLocked(ctx->Shared->SamplerObjects, first + i, sampObj);
-      samplers[i] = first + i;
+      struct gl_sampler_object *sampObj;
+      GLuint name = first + i;
+
+      sampObj = ctx->Driver.NewSamplerObject(ctx, name);
+      if (!sampObj) {
+         _mesa_HashUnlockMutex(ctx->Shared->SamplerObjects);
+         _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
+         return;
+      }
+
+      _mesa_HashInsertLocked(ctx->Shared->SamplerObjects, name, sampObj);
+      samplers[i] = name;
    }
 
    _mesa_HashUnlockMutex(ctx->Shared->SamplerObjects);