d3dx9: Correctly handle NULL constant state for objects on 64 bit arch.

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 2019-11-06 10:06:29 +01:00 committed by Alexandre Julliard
parent 781fc47f36
commit aef11864a4
1 changed files with 31 additions and 4 deletions

View File

@ -5345,8 +5345,11 @@ static HRESULT d3dx_parse_effect_annotation(struct d3dx_effect *effect, struct d
static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *state, static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *state,
const char *data, const char **ptr, struct d3dx_object *objects) const char *data, const char **ptr, struct d3dx_object *objects)
{ {
DWORD offset; struct d3dx_parameter *param = &state->parameter;
enum STATE_CLASS state_class;
const char *ptr2; const char *ptr2;
void *new_data;
DWORD offset;
HRESULT hr; HRESULT hr;
state->type = ST_CONSTANT; state->type = ST_CONSTANT;
@ -5360,7 +5363,7 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s
read_dword(ptr, &offset); read_dword(ptr, &offset);
TRACE("Typedef offset: %#x\n", offset); TRACE("Typedef offset: %#x\n", offset);
ptr2 = data + offset; ptr2 = data + offset;
hr = d3dx_parse_effect_typedef(effect, &state->parameter, data, &ptr2, NULL, 0); hr = d3dx_parse_effect_typedef(effect, param, data, &ptr2, NULL, 0);
if (hr != D3D_OK) if (hr != D3D_OK)
{ {
WARN("Failed to parse type definition\n"); WARN("Failed to parse type definition\n");
@ -5369,18 +5372,42 @@ static HRESULT d3dx_parse_state(struct d3dx_effect *effect, struct d3dx_state *s
read_dword(ptr, &offset); read_dword(ptr, &offset);
TRACE("Value offset: %#x\n", offset); TRACE("Value offset: %#x\n", offset);
hr = d3dx_parse_init_value(effect, &state->parameter, data, data + offset, objects); hr = d3dx_parse_init_value(effect, param, data, data + offset, objects);
if (hr != D3D_OK) if (hr != D3D_OK)
{ {
WARN("Failed to parse value\n"); WARN("Failed to parse value\n");
goto err_out; goto err_out;
} }
if (((state_class = state_table[state->operation].class) == SC_VERTEXSHADER
|| state_class == SC_PIXELSHADER || state_class == SC_TEXTURE)
&& param->bytes < sizeof(void *))
{
if (param->type != D3DXPT_INT || *(unsigned int *)param->data)
{
FIXME("Unexpected parameter for object, param->type %#x, param->class %#x, *param->data %#x.\n",
param->type, param->class, *(unsigned int *)param->data);
hr = D3DXERR_INVALIDDATA;
goto err_out;
}
new_data = heap_realloc(param->data, sizeof(void *));
if (!new_data)
{
ERR("Out of memory.\n");
hr = E_OUTOFMEMORY;
goto err_out;
}
memset(new_data, 0, sizeof(void *));
param->data = new_data;
param->bytes = sizeof(void *);
}
return D3D_OK; return D3D_OK;
err_out: err_out:
free_parameter(&state->parameter, FALSE, FALSE); free_parameter(param, FALSE, FALSE);
return hr; return hr;
} }