diff options
author | Pauli Nieminen <pauli.nieminen@linux.intel.com> | 2012-06-08 23:43:33 +0300 |
---|---|---|
committer | Pauli Nieminen <pauli.nieminen@linux.intel.com> | 2012-06-10 00:26:25 +0300 |
commit | 32b7a3c91260fb16411553fdfcfb0f6a580eb5de (patch) | |
tree | 0ac989533304a8327eb6f6a98d88b1cefd854cf1 | |
parent | d9a7d39fdee8499c16c5feb2cc5ad8d8c247d166 (diff) |
mesa/samplerobj: Avoid crash in sampler query if texture unit is disabled
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@linux.intel.com>
-rw-r--r-- | src/mesa/main/samplerobj.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h index 0bfda43517..33da894e8f 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; } |