diff options
author | Brian Paul <[email protected]> | 2013-07-02 14:51:30 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-07-12 08:32:51 -0600 |
commit | 5749aea255446b850a1b56f944a062358e5c70dd (patch) | |
tree | 99539d59122f85febc2b4f59ca54c6674cdbac80 /src | |
parent | 9ca026e220f4bdec8cf0022387691a186809a677 (diff) |
mesa: fix Address Sanitizer (ASan) issue in _mesa_add_parameter()
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/program/prog_parameter.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c index 95b153e16bd..4d9cf08d211 100644 --- a/src/mesa/program/prog_parameter.c +++ b/src/mesa/program/prog_parameter.c @@ -155,7 +155,21 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, 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; } |