diff options
author | Brian <[email protected]> | 2007-08-07 21:46:42 +0100 |
---|---|---|
committer | Brian <[email protected]> | 2007-08-07 21:46:42 +0100 |
commit | 5abf0551008f401e1e291e9a295b8e66e02e01d6 (patch) | |
tree | fc2a0eca65cc7be19a2f602cda31405e2492fa6b /src | |
parent | 4bb5721f6b35d8dbea3110fa096181b165e996b3 (diff) |
fix potential NULL dereference (bug 11880)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/shader/shader_api.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index b794e30e970..06d24b4bf0f 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -378,7 +378,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) { @@ -387,6 +387,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 */ @@ -548,7 +550,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) { @@ -557,6 +559,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 */ |