If the size argument isn't a multiple of four, we would have read/
copied uninitialized memory.
Fixes an issue reported by Myles C. Maxfield <myles.maxfield@gmail.com>
p->Size = size;
p->DataType = datatype;
if (values) {
- COPY_4V(paramList->ParameterValues[oldNum + i], values);
+ if (size >= 4) {
+ COPY_4V(paramList->ParameterValues[oldNum + i], values);
+ }
+ else {
+ /* copy 1, 2 or 3 values */
+ GLuint remaining = size % 4;
+ assert(remaining < 4);
+ for (j = 0; j < remaining; j++) {
+ paramList->ParameterValues[oldNum + i][j].f = values[j].f;
+ }
+ /* fill in remaining positions with zeros */
+ for (; j < 4; j++) {
+ paramList->ParameterValues[oldNum + i][j].f = 0.0f;
+ }
+ }
values += 4;
p->Initialized = GL_TRUE;
}