d3dx9: Return an error for out of bounds input register in parse_preshader().

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2017-04-27 14:05:46 +03:00 committed by Alexandre Julliard
parent 5b38f1cf2e
commit 30bc3bab30
1 changed files with 7 additions and 2 deletions

View File

@ -749,6 +749,7 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
pres->regs.table_sizes[PRES_REGTAB_IMMED] = const_count; pres->regs.table_sizes[PRES_REGTAB_IMMED] = const_count;
update_table_sizes_consts(pres->regs.table_sizes, &pres->inputs);
for (i = 0; i < pres->ins_count; ++i) for (i = 0; i < pres->ins_count; ++i)
{ {
for (j = 0; j < pres_op_info[pres->ins[i].op].input_count; ++j) for (j = 0; j < pres_op_info[pres->ins[i].op].input_count; ++j)
@ -770,13 +771,17 @@ static HRESULT parse_preshader(struct d3dx_preshader *pres, unsigned int *ptr, u
table = pres->ins[i].inputs[j].index_reg.table; table = pres->ins[i].inputs[j].index_reg.table;
reg_idx = get_reg_offset(table, pres->ins[i].inputs[j].index_reg.offset); reg_idx = get_reg_offset(table, pres->ins[i].inputs[j].index_reg.offset);
} }
update_table_size(pres->regs.table_sizes, table, reg_idx); if (reg_idx >= pres->regs.table_sizes[table])
{
FIXME("Out of bounds register index, i %u, j %u, table %u, reg_idx %u.",
i, j, table, reg_idx);
return D3DXERR_INVALIDDATA;
}
} }
update_table_size(pres->regs.table_sizes, pres->ins[i].output.reg.table, update_table_size(pres->regs.table_sizes, pres->ins[i].output.reg.table,
get_reg_offset(pres->ins[i].output.reg.table, get_reg_offset(pres->ins[i].output.reg.table,
pres->ins[i].output.reg.offset + pres->ins[i].component_count - 1)); pres->ins[i].output.reg.offset + pres->ins[i].component_count - 1));
} }
update_table_sizes_consts(pres->regs.table_sizes, &pres->inputs);
if (FAILED(regstore_alloc_table(&pres->regs, PRES_REGTAB_IMMED))) if (FAILED(regstore_alloc_table(&pres->regs, PRES_REGTAB_IMMED)))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
regstore_set_values(&pres->regs, PRES_REGTAB_IMMED, dconst, 0, const_count); regstore_set_values(&pres->regs, PRES_REGTAB_IMMED, dconst, 0, const_count);