diff options
author | Brian <[email protected]> | 2007-02-25 19:01:16 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2007-02-25 19:01:16 -0700 |
commit | 313d50e9036558185e189873acb861bfa73f41a1 (patch) | |
tree | a22e2e6e841ab75e88cb9a1184abf8ae0276e2a6 /src/mesa | |
parent | b85d4d61a7f93a9f2d58a1d701808584e0fce8c7 (diff) |
fix bounds checking in get_register_pointer()
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/shader/prog_execute.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c index 2db4e695228..d42b2e99b94 100644 --- a/src/mesa/shader/prog_execute.c +++ b/src/mesa/shader/prog_execute.c @@ -84,14 +84,20 @@ get_register_pointer(const struct prog_src_register *source, { if (source->RelAddr) { const GLint reg = source->Index + machine->AddressReg[0][0]; - if (reg < 0 || reg > MAX_NV_VERTEX_PROGRAM_PARAMS) - return ZeroVec; - else if (source->File == PROGRAM_ENV_PARAM) - return machine->EnvParams[reg]; + if (source->File == PROGRAM_ENV_PARAM) + if (reg < 0 || reg >= MAX_PROGRAM_ENV_PARAMS) + return ZeroVec; + else + return machine->EnvParams[reg]; else { + const struct gl_program_parameter_list *params; ASSERT(source->File == PROGRAM_LOCAL_PARAM || source->File == PROGRAM_STATE_VAR); - return machine->CurProgram->Parameters->ParameterValues[reg]; + params = machine->CurProgram->Parameters; + if (reg < 0 || reg >= params->NumParameters) + return ZeroVec; + else + return params->ParameterValues[reg]; } } |