[Mesa-dev] [PATCH 08/21] mesa/samplerobj: Avoid crash in sampler query if texture unit is disabled
Brian Paul
brianp at vmware.com
Mon Jun 11 08:36:46 PDT 2012
On 06/11/2012 12:59 AM, Pauli Nieminen wrote:
> Sampler queries are so far made only for enabled texture unit. But if
> any code would query sampler before checking texture unit state that
> would result to NULL deference.
>
> Making the inline helper easier to use with NULL check makes a lot sense
> because compiler is likely to combine the checks for the current texture.
>
> Signed-off-by: Pauli Nieminen<pauli.nieminen at linux.intel.com>
> ---
> src/mesa/main/samplerobj.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
> index 0bfda43..33da894 100644
> --- a/src/mesa/main/samplerobj.h
> +++ b/src/mesa/main/samplerobj.h
> @@ -33,8 +33,10 @@ _mesa_get_samplerobj(struct gl_context *ctx, GLuint unit)
> {
> if (ctx->Texture.Unit[unit].Sampler)
> return ctx->Texture.Unit[unit].Sampler;
> - else
> + else if (ctx->Texture.Unit[unit]._Current)
> return&ctx->Texture.Unit[unit]._Current->Sampler;
> + else
> + return NULL;
> }
>
>
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list