Commit 0c8e78f8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Don't assert on invalid IDirect3DBaseTexture9 interfaces.

parent cd59e3db
...@@ -6627,8 +6627,9 @@ static void test_filter(void) ...@@ -6627,8 +6627,9 @@ static void test_filter(void)
DestroyWindow(window); DestroyWindow(window);
} }
static void test_get_texture(void) static void test_get_set_texture(void)
{ {
const IDirect3DBaseTexture9Vtbl *texture_vtbl;
IDirect3DBaseTexture9 *texture; IDirect3DBaseTexture9 *texture;
IDirect3DDevice9 *device; IDirect3DDevice9 *device;
IDirect3D9 *d3d; IDirect3D9 *d3d;
...@@ -6655,6 +6656,23 @@ static void test_get_texture(void) ...@@ -6655,6 +6656,23 @@ static void test_get_texture(void)
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(!texture, "Got unexpected texture %p.\n", texture); ok(!texture, "Got unexpected texture %p.\n", texture);
hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, 0, D3DFMT_A8R8G8B8,
D3DPOOL_MANAGED, (IDirect3DTexture9 **)&texture, NULL);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
texture_vtbl = texture->lpVtbl;
texture->lpVtbl = (IDirect3DBaseTexture9Vtbl *)0xdeadbeef;
hr = IDirect3DDevice9_SetTexture(device, 0, texture);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
texture->lpVtbl = NULL;
hr = IDirect3DDevice9_SetTexture(device, 0, texture);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
texture->lpVtbl = texture_vtbl;
IDirect3DBaseTexture9_Release(texture);
refcount = IDirect3DDevice9_Release(device); refcount = IDirect3DDevice9_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount); ok(!refcount, "Device has %u references left.\n", refcount);
IDirect3D9_Release(d3d); IDirect3D9_Release(d3d);
...@@ -10231,7 +10249,7 @@ START_TEST(device) ...@@ -10231,7 +10249,7 @@ START_TEST(device)
test_cube_textures(); test_cube_textures();
test_mipmap_gen(); test_mipmap_gen();
test_filter(); test_filter();
test_get_texture(); test_get_set_texture();
test_lod(); test_lod();
test_surface_get_container(); test_surface_get_container();
test_surface_alignment(); test_surface_alignment();
......
...@@ -1252,9 +1252,15 @@ struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture ...@@ -1252,9 +1252,15 @@ struct d3d9_texture *unsafe_impl_from_IDirect3DBaseTexture9(IDirect3DBaseTexture
{ {
if (!iface) if (!iface)
return NULL; return NULL;
assert(iface->lpVtbl == (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_2d_vtbl
|| iface->lpVtbl == (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_cube_vtbl if (iface->lpVtbl != (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_2d_vtbl
|| iface->lpVtbl == (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_3d_vtbl); && iface->lpVtbl != (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_cube_vtbl
&& iface->lpVtbl != (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_3d_vtbl)
{
WARN("%p is not a valid IDirect3DBaseTexture9 interface.\n", iface);
return NULL;
}
return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface); return CONTAINING_RECORD(iface, struct d3d9_texture, IDirect3DBaseTexture9_iface);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment