Mesa (master): mesa: Make sure the buffer exists in _mesa_lookup_bufferobj_err

Fredrik Höglund fredrik at kemper.freedesktop.org
Fri Mar 20 00:38:11 UTC 2015


Module: Mesa
Branch: master
Commit: 2fd21d8a84bd28461c964e2ab350389a55b7f001
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2fd21d8a84bd28461c964e2ab350389a55b7f001

Author: Fredrik Höglund <fredrik at kde.org>
Date:   Thu Mar 19 19:44:57 2015 +0100

mesa: Make sure the buffer exists in _mesa_lookup_bufferobj_err

Generate GL_INVALID_OPERATION and return NULL when the buffer object
hasn't been created.  All callers expect this.

v2: Use a more concise error message.

Cc: Laura Ekstrand <laura at jlekstrand.net>
Reviewed-by: Laura Ekstrand <laura at jlekstrand.net>

---

 src/mesa/main/bufferobj.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 78d3d78..9658770 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1003,8 +1003,8 @@ _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer)
 
 /**
  * A convenience function for direct state access functions that throws
- * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the
- * hash table.
+ * GL_INVALID_OPERATION if buffer is not the name of an existing
+ * buffer object.
  */
 struct gl_buffer_object *
 _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
@@ -1013,9 +1013,11 @@ _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
    struct gl_buffer_object *bufObj;
 
    bufObj = _mesa_lookup_bufferobj(ctx, buffer);
-   if (!bufObj)
+   if (!bufObj || bufObj == &DummyBufferObject) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "%s(non-generated buffer name %u)", caller, buffer);
+                  "%s(non-existent buffer object %u)", caller, buffer);
+      return NULL;
+   }
 
    return bufObj;
 }




More information about the mesa-commit mailing list