mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 22:49:13 +02:00
glsl: fix glUniform() array bounds error checking
If too many array elements are specified, they're to be silently ignored (don't raise a GL error). Fixes another issue in bug 20056.
This commit is contained in:
parent
369d1859d7
commit
2c1ea0720d
1 changed files with 21 additions and 9 deletions
|
|
@ -1616,19 +1616,31 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
|
|||
else {
|
||||
/* ordinary uniform variable */
|
||||
GLsizei k, i;
|
||||
GLint slots = (param->Size + 3) / 4;
|
||||
const GLint slots = (param->Size + 3) / 4;
|
||||
const GLint typeSize = sizeof_glsl_type(param->DataType);
|
||||
|
||||
if (count * elems > (GLint) param->Size) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(count too large)");
|
||||
return;
|
||||
if (param->Size > typeSize) {
|
||||
/* an array */
|
||||
/* we'll ignore extra data below */
|
||||
}
|
||||
else {
|
||||
/* non-array: count must be one */
|
||||
if (count != 1) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glUniform(uniform is not an array)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > slots)
|
||||
count = slots;
|
||||
|
||||
for (k = 0; k < count; k++) {
|
||||
GLfloat *uniformVal =
|
||||
program->Parameters->ParameterValues[index + offset + k];
|
||||
GLfloat *uniformVal;
|
||||
|
||||
if (offset + k > slots) {
|
||||
/* Extra array data is ignored */
|
||||
break;
|
||||
}
|
||||
|
||||
uniformVal = program->Parameters->ParameterValues[index + offset + k];
|
||||
if (is_integer_type(type)) {
|
||||
const GLint *iValues = ((const GLint *) values) + k * elems;
|
||||
for (i = 0; i < elems; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue