mesa: check that buffer object is not NULL before initializing it
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 26 Jul 2017 22:53:08 +0000 (08:53 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 27 Jul 2017 12:19:52 +0000 (22:19 +1000)
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/mesa/main/bufferobj.c

index cb666dcf13fabeb9a2276f2e797fad0686c83d81..cd561a0a2710bc2071304822d7129a03f686a8ff 100644 (file)
@@ -443,11 +443,10 @@ convert_clear_buffer_data(struct gl_context *ctx,
 static struct gl_buffer_object *
 _mesa_new_buffer_object(struct gl_context *ctx, GLuint name)
 {
-   struct gl_buffer_object *obj;
-
-   (void) ctx;
+   struct gl_buffer_object *obj = MALLOC_STRUCT(gl_buffer_object);
+   if (!obj)
+      return NULL;
 
-   obj = MALLOC_STRUCT(gl_buffer_object);
    _mesa_initialize_buffer_object(ctx, obj, name);
    return obj;
 }