diff options
author | Kenneth Graunke <[email protected]> | 2012-07-19 13:41:34 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2012-10-12 20:07:41 -0700 |
commit | f9aefaeb274a480579e7b8437003bdf92d839153 (patch) | |
tree | a3f1daf4d921c5c756c2a0350ec00d02ee11549a | |
parent | c33b752899d26ecacb7affa76e90632436294974 (diff) |
mesa: Prevent repeated glDeleteShader() from blowing away our refcounts.
Calling glDeleteShader() should mark shaders as pending for deletion,
but shouldn't decrement the refcount every time. Otherwise, repeated
glDeleteShader() is not safe.
This is particularly bad since glDeleteProgram() frees shaders: if you
first call glDeleteShader() on the shaders attached to the program (thus
decrementing the refcount), then called glDeleteProgram(), it would try
to free them again (decrementing the refcount another time), causing
a refcount > 0 assertion to fail.
Similar to commit d950a778.
NOTE: This is a candidate for the 8.0 branch.
Signed-off-by: Kenneth Graunke <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
(cherry picked from commit c3bc41011f9ffe648b7dd4915c6202b776cd1ab4)
-rw-r--r-- | src/mesa/main/shaderapi.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 8b68ebf9c87..7c70aa6bfad 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -404,10 +404,12 @@ delete_shader(struct gl_context *ctx, GLuint shader) if (!sh) return; - sh->DeletePending = GL_TRUE; + if (!sh->DeletePending) { + sh->DeletePending = GL_TRUE; - /* effectively, decr sh's refcount */ - _mesa_reference_shader(ctx, &sh, NULL); + /* effectively, decr sh's refcount */ + _mesa_reference_shader(ctx, &sh, NULL); + } } |