mesa: Avoid segfault when getting an unbound transform feedback buffer name.
authorPaul Berry <stereotype441@gmail.com>
Tue, 3 Jan 2012 21:59:13 +0000 (13:59 -0800)
committerPaul Berry <stereotype441@gmail.com>
Thu, 5 Jan 2012 21:27:12 +0000 (13:27 -0800)
Previously we were using
gl_transform_feedback_object::Buffers[i]->Name to service an indexed
get request for GL_TRANSFORM_FEEDBACK_BUFFER_BINDING.  However, if no
buffer has been bound, gl_transform_feedback_object::Buffers[i] is
NULL, so this was causing a segfault.

This patch switches to using
gl_transform_feedback_object::BufferNames[i], which is equal to
gl_transform_feedback_object::Buffers[i]->Name if
gl_transform_feedback_object::Buffers[i] is not NULL, and 0 if it is
NULL.

Fixes piglit test "EXT_transform_feedback/get-buffer-state
indexed_binding".

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/get.c

index 0c9d6b391d4faa0999c6522f65017c8b7e837d77..5ad601242f476e6a5ff014c8b7d9c33d4b9f350e 100644 (file)
@@ -2498,7 +2498,7 @@ find_value_indexed(const char *func, GLenum pname, int index, union value *v)
         goto invalid_value;
       if (!ctx->Extensions.EXT_transform_feedback)
         goto invalid_enum;
-      v->value_int = ctx->TransformFeedback.CurrentObject->Buffers[index]->Name;
+      v->value_int = ctx->TransformFeedback.CurrentObject->BufferNames[index];
       return TYPE_INT;
    }