Module: wine Branch: master Commit: cfae1ceb04a7e492c344190a656595f1c60af41f URL: https://gitlab.winehq.org/wine/wine/-/commit/cfae1ceb04a7e492c344190a656595f...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Fri May 13 10:44:49 2022 +1000
d3drm: Correct D3DRMIMAGE validation.
---
dlls/d3drm/tests/d3drm.c | 17 +++++++++++++++++ dlls/d3drm/texture.c | 27 ++++++++++++++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 6922a70df24..5d478f24b1a 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2724,6 +2724,12 @@ static void test_Texture(void) TRUE, 0, (void *)0xcafebabe, NULL, 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, NULL }, + testimg_palette = + { + 2, 2, 1, 1, 32, + FALSE, 2 * sizeof(DWORD), (void *)0xcafebabe, NULL, + 0x00000000, 0x00000000, 0x00000000, 0, 2, (void *)0xcafebabe + }, *d3drm_img = NULL;
DWORD pixel[4] = { 20000, 30000, 10000, 0 }; @@ -2785,6 +2791,17 @@ static void test_Texture(void) IDirect3DRMTexture2_Release(texture2); IDirect3DRMTexture3_Release(texture3);
+ /* Just palette set */ + hr = IDirect3DRM_CreateTexture(d3drm1, &testimg_palette, &texture1); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture interface, hr %#lx\n", hr); + hr = IDirect3DRM2_CreateTexture(d3drm2, &testimg_palette, &texture2); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture2 interface, hr %#lx\n", hr); + hr = IDirect3DRM3_CreateTexture(d3drm3, &testimg_palette, &texture3); + ok(SUCCEEDED(hr), "Cannot get IDirect3DRMTexture3 interface, hr %#lx\n", hr); + IDirect3DRMTexture_Release(texture1); + IDirect3DRMTexture2_Release(texture2); + IDirect3DRMTexture3_Release(texture3); + initimg.rgb = 0; texture1 = (IDirect3DRMTexture *)0xdeadbeef; hr = IDirect3DRM_CreateTexture(d3drm1, &initimg, &texture1); diff --git a/dlls/d3drm/texture.c b/dlls/d3drm/texture.c index b9d84114995..f0983d53e24 100644 --- a/dlls/d3drm/texture.c +++ b/dlls/d3drm/texture.c @@ -52,14 +52,27 @@ static void d3drm_texture_destroy(struct d3drm_texture *texture)
static BOOL d3drm_validate_image(D3DRMIMAGE *image) { - if (!image - || !image->red_mask - || !image->green_mask - || !image->blue_mask - || !image->buffer1 - || !(image->rgb || (image->palette && image->palette_size))) - { + if (!image) return FALSE; + + TRACE("size (%d, %d), aspect (%d, %d), depth %d, red %#lx, green %#lx, blue %#lx, " + "buffer1 %p, buffer2 %p, rgb %d, pal %p, size %d\n", + image->width, image->height, image->aspectx, image->aspecty, + image->depth, image->red_mask, image->green_mask, image->blue_mask, image->buffer1, + image->buffer2, image->rgb, image->palette, image->palette_size ); + + if (!image->buffer1) + return FALSE; + + if (image->rgb) + { + if (!image->red_mask || !image->green_mask || !image->blue_mask) + return FALSE; + } + else + { + if (!image->palette || !image->palette_size) + return FALSE; }
return TRUE;