From 237b985356b4d791ee2f184a201de9704614b9b1 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 7 Aug 2007 21:48:31 +0100 Subject: [PATCH] fix potential NULL dereference (bug 11880) --- src/mesa/shader/shader_api.c | 8 ++++++-- 1 file 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 */ -- 2.30.2