fix bounds checking in get_register_pointer()
authorBrian <brian@nostromo.localnet.net>
Mon, 26 Feb 2007 02:01:16 +0000 (19:01 -0700)
committerBrian <brian@nostromo.localnet.net>
Mon, 26 Feb 2007 02:01:16 +0000 (19:01 -0700)
src/mesa/shader/prog_execute.c

index 2db4e6952281798689533dc0cdfd20d2998fdce5..d42b2e99b94e21c2b6fecfda62c2e751e96c5acf 100644 (file)
@@ -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];
       }
    }