Module: wine Branch: master Commit: be68d56efc0e7dc1a6aab644ad3fabfa5650fc6e URL: http://source.winehq.org/git/wine.git/?a=commit;h=be68d56efc0e7dc1a6aab644ad...
Author: Rico Schüller kgbricola@web.de Date: Tue Oct 25 10:39:25 2011 +0200
d3dx9: Improve argument check in D3DXFindShaderComment().
---
dlls/d3dx9_36/shader.c | 3 +++ dlls/d3dx9_36/tests/shader.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/d3dx9_36/shader.c b/dlls/d3dx9_36/shader.c index bc5e002..b538edd 100644 --- a/dlls/d3dx9_36/shader.c +++ b/dlls/d3dx9_36/shader.c @@ -153,6 +153,9 @@ HRESULT WINAPI D3DXFindShaderComment(CONST DWORD* byte_code, DWORD fourcc, LPCVO
TRACE("(%p, %x, %p, %p)\n", byte_code, fourcc, data, size);
+ if (data) *data = NULL; + if (size) *size = 0; + if (!byte_code) return D3DERR_INVALIDCALL;
diff --git a/dlls/d3dx9_36/tests/shader.c b/dlls/d3dx9_36/tests/shader.c index 9220e28..8d82a68 100644 --- a/dlls/d3dx9_36/tests/shader.c +++ b/dlls/d3dx9_36/tests/shader.c @@ -215,23 +215,31 @@ static void test_get_shader_version(void) static void test_find_shader_comment(void) { HRESULT hr; - LPCVOID data; - UINT size; + LPCVOID data = (LPVOID)0xdeadbeef; + UINT size = 100;
hr = D3DXFindShaderComment(NULL, MAKEFOURCC('C','T','A','B'), &data, &size); ok(hr == D3DERR_INVALIDCALL, "Got result %x, expected %x (D3DERR_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); + ok(!data, "Got %p, expected NULL\n", data); + ok(!size, "Got %u, expected 0\n", size);
hr = D3DXFindShaderComment(shader_with_ctab, MAKEFOURCC('C','T','A','B'), NULL, &size); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + ok(size == 28, "Got %u, expected 28\n", size);
hr = D3DXFindShaderComment(shader_with_ctab, MAKEFOURCC('C','T','A','B'), &data, NULL); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr); + ok(data == (LPCVOID)(shader_with_ctab + 6), "Got result %p, expected %p\n", data, shader_with_ctab + 6);
hr = D3DXFindShaderComment(shader_with_ctab, 0, &data, &size); ok(hr == S_FALSE, "Got result %x, expected 1 (S_FALSE)\n", hr); + ok(!data, "Got %p, expected NULL\n", data); + ok(!size, "Got %u, expected 0\n", size);
hr = D3DXFindShaderComment(shader_with_ctab, MAKEFOURCC('X','X','X','X'), &data, &size); ok(hr == S_FALSE, "Got result %x, expected 1 (S_FALSE)\n", hr); + ok(!data, "Got %p, expected NULL\n", data); + ok(!size, "Got %u, expected 0\n", size);
hr = D3DXFindShaderComment(shader_with_ctab, MAKEFOURCC('C','T','A','B'), &data, &size); ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK)\n", hr);