mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-04 20:38:06 +02:00
[965] Fix potential segfaults from bad realloc.
C has no order of evaluation restrictions on function arguments, so we attempted to realloc from new-size to new-size.
This commit is contained in:
parent
c9b1fef0c9
commit
e747e9a072
1 changed files with 4 additions and 1 deletions
|
|
@ -524,10 +524,13 @@ static void emit_op3fn(struct tnl_program *p,
|
|||
GLuint nr = p->program->Base.NumInstructions++;
|
||||
|
||||
if (nr >= p->nr_instructions) {
|
||||
int new_nr_instructions = p->nr_instructions * 2;
|
||||
|
||||
p->program->Base.Instructions =
|
||||
_mesa_realloc(p->program->Base.Instructions,
|
||||
sizeof(struct prog_instruction) * p->nr_instructions,
|
||||
sizeof(struct prog_instruction) * (p->nr_instructions *= 2));
|
||||
sizeof(struct prog_instruction) * new_nr_instructions);
|
||||
p->nr_instructions = new_nr_instructions;
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue