summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/shader_api.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-07 21:48:31 +0100
committerBrian <[email protected]>2007-08-07 21:48:31 +0100
commit237b985356b4d791ee2f184a201de9704614b9b1 (patch)
tree3fd9cdc08f911ba49312fd80b143585470a7e449 /src/mesa/shader/shader_api.c
parent872d1791414cd39df03f35330c1e7e9d88f229b3 (diff)
fix potential NULL dereference (bug 11880)
Diffstat (limited to 'src/mesa/shader/shader_api.c')
-rw-r--r--src/mesa/shader/shader_api.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 1a931326afa..a1e73ef125c 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -377,7 +377,7 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader)
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
struct gl_shader *sh = _mesa_lookup_shader(ctx, shader);
- const GLuint n = shProg->NumShaders;
+ GLuint n;
GLuint i;
if (!shProg || !sh) {
@@ -386,6 +386,8 @@ _mesa_attach_shader(GLcontext *ctx, GLuint program, GLuint shader)
return;
}
+ n = shProg->NumShaders;
+
for (i = 0; i < n; i++) {
if (shProg->Shaders[i] == sh) {
/* already attached */
@@ -547,7 +549,7 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader)
{
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
- const GLuint n = shProg->NumShaders;
+ GLuint n;
GLuint i, j;
if (!shProg) {
@@ -556,6 +558,8 @@ _mesa_detach_shader(GLcontext *ctx, GLuint program, GLuint shader)
return;
}
+ n = shProg->NumShaders;
+
for (i = 0; i < n; i++) {
if (shProg->Shaders[i]->Name == shader) {
/* found it */