diff options
author | Pauli Nieminen <[email protected]> | 2012-06-12 21:38:48 +0300 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2012-08-12 16:18:41 -0700 |
commit | ac4dc5e9312f3ef154135a68521e7a20c88b7837 (patch) | |
tree | 95936af071cf6883dde9c4911cdde974e1fa9dd3 /src/mesa | |
parent | 5606bd574e264c4beda8eb1d10b48d17e9b8b497 (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 <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-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 2b0cd794665..e70ee4881ad 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; } |