d3dx9: Handle invalid byte code in D3DXGetShaderConstantTableEx().

oldstable
Rico Schüller 2013-01-07 21:57:18 +01:00 committed by Alexandre Julliard
parent a847b9dddb
commit 6cb4301021
2 changed files with 21 additions and 0 deletions

View File

@ -1639,6 +1639,12 @@ HRESULT WINAPI D3DXGetShaderConstantTableEx(const DWORD *byte_code, DWORD flags,
return D3DERR_INVALIDCALL;
}
if (!is_valid_bytecode(*byte_code))
{
WARN("Invalid byte_code specified.\n");
return D3D_OK;
}
if (flags) FIXME("Flags (%#x) are not handled, yet!\n", flags);
hr = D3DXFindShaderComment(byte_code, MAKEFOURCC('C','T','A','B'), &data, &size);

View File

@ -366,6 +366,21 @@ static void test_get_shader_constant_table_ex(void)
ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL);
ok(constant_table == NULL, "D3DXGetShaderConstantTableEx() failed, got %p\n", constant_table);
constant_table = (ID3DXConstantTable *)0xdeadbeef;
hr = D3DXGetShaderConstantTableEx(shader_zero, 0, &constant_table);
ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
ok(constant_table == NULL, "D3DXGetShaderConstantTableEx() failed, got %p\n", constant_table);
constant_table = (ID3DXConstantTable *)0xdeadbeef;
hr = D3DXGetShaderConstantTableEx(shader_invalid, 0, &constant_table);
ok(hr == D3D_OK, "Got result %x, expected %x (D3D_OK)\n", hr, D3D_OK);
ok(constant_table == NULL, "D3DXGetShaderConstantTableEx() failed, got %p\n", constant_table);
constant_table = (ID3DXConstantTable *)0xdeadbeef;
hr = D3DXGetShaderConstantTableEx(shader_empty, 0, &constant_table);
ok(hr == D3DXERR_INVALIDDATA, "Got result %x, expected %x (D3DXERR_INVALIDDATA)\n", hr, D3DXERR_INVALIDDATA);
ok(constant_table == NULL, "D3DXGetShaderConstantTableEx() failed, got %p\n", constant_table);
/* No CTAB data */
constant_table = (ID3DXConstantTable *)0xdeadbeef;
hr = D3DXGetShaderConstantTableEx(simple_ps, 0, &constant_table);