From 6cb430102117b21fa96009c774af9e5c99e61777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rico=20Sch=C3=BCller?= Date: Mon, 7 Jan 2013 21:57:18 +0100 Subject: [PATCH] d3dx9: Handle invalid byte code in D3DXGetShaderConstantTableEx(). --- dlls/d3dx9_36/shader.c | 6 ++++++ dlls/d3dx9_36/tests/shader.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c index e266fe2272f..81c832324b1 100644 --- a/dlls/d3dx9_36/shader.c +++ b/dlls/d3dx9_36/shader.c @@ -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); diff --git a/dlls/d3dx9_36/tests/shader.c b/dlls/d3dx9_36/tests/shader.c index fb8f270b074..f7be1749f8c 100644 --- a/dlls/d3dx9_36/tests/shader.c +++ b/dlls/d3dx9_36/tests/shader.c @@ -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);