[Mesa-stable] [PATCH] mesa/main: Prevent sefgault on glGetIntegerv(GL_ATOMIC_COUNTER_BUFFER_BINDING).

Brian Paul brianp at vmware.com
Fri Jun 6 16:06:07 PDT 2014


On 06/06/2014 03:59 PM, jfonseca at vmware.com wrote:
> From: José Fonseca <jfonseca at vmware.com>
>
> A recent ApiTrace change, that tries to dump more buffer state
> causes Mesa from my distro (10.1.4) to segfaults here.
>
> I haven't actually confirm this fixes it (I can't repro on master),
> but it seems a good idea to be defensive here anyway.
>
> Cc: "10.1 10.2" <mesa-stable at lists.freedesktop.org>
> ---
>   src/mesa/main/get.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index 267b5f2..9b56edb 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -1005,7 +1005,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
>         break;
>      /* GL_ARB_shader_atomic_counters */
>      case GL_ATOMIC_COUNTER_BUFFER_BINDING:
> -      v->value_int = ctx->AtomicBuffer->Name;
> +      if (ctx->AtomicBuffer) {
> +         v->value_int = ctx->AtomicBuffer->Name;
> +      } else {
> +         v->value_int = 0;
> +      }
>         break;
>      /* GL_ARB_draw_indirect */
>      case GL_DRAW_INDIRECT_BUFFER_BINDING:
>

Which driver?  Is the extensions really enabled?  If not, I'd have 
expected glGet(GL_ATOMIC_COUNTER_BUFFER_BINDING) to raise a GL error and 
return early.

In any case, this change looks good to me.  I'm wondering if the next 
switch case also needs similar treatment:

    case GL_DRAW_INDIRECT_BUFFER_BINDING:
       v->value_int = ctx->DrawIndirectBuffer->Name;
       break;


Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-stable mailing list