Module: wine Branch: master Commit: 8692b3c0fe7d6e36f1cb4c27d9337a2e956bb715 URL: https://gitlab.winehq.org/wine/wine/-/commit/8692b3c0fe7d6e36f1cb4c27d9337a2...
Author: Connor McAdams cmcadams@codeweavers.com Date: Mon Jul 1 06:39:36 2024 -0400
d3dx9: Return failure if a cubemap DDS file does not contain all faces.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
---
dlls/d3dx9_36/surface.c | 11 +++++------ dlls/d3dx9_36/tests/surface.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/d3dx9_36/surface.c b/dlls/d3dx9_36/surface.c index 6d12872a647..79ee4edcbc1 100644 --- a/dlls/d3dx9_36/surface.c +++ b/dlls/d3dx9_36/surface.c @@ -645,14 +645,13 @@ static HRESULT d3dx_initialize_image_from_dds(const void *src_data, uint32_t src } else if (header->caps2 & DDS_CAPS2_CUBEMAP) { - DWORD face; - - faces = 0; - for (face = DDS_CAPS2_CUBEMAP_POSITIVEX; face <= DDS_CAPS2_CUBEMAP_NEGATIVEZ; face <<= 1) + if ((header->caps2 & DDS_CAPS2_CUBEMAP_ALL_FACES) != DDS_CAPS2_CUBEMAP_ALL_FACES) { - if (header->caps2 & face) - faces++; + WARN("Tried to load a partial cubemap DDS file.\n"); + return D3DXERR_INVALIDDATA; } + + faces = 6; image->resource_type = D3DRTYPE_CUBETEXTURE; } else diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c index ebca259e551..5fca2f5d64d 100644 --- a/dlls/d3dx9_36/tests/surface.c +++ b/dlls/d3dx9_36/tests/surface.c @@ -408,7 +408,7 @@ static void test_dds_header_handling(void) /* Partial cubemaps are not supported. */ { (DDS_CAPS | DDS_WIDTH | DDS_HEIGHT | DDS_PIXELFORMAT), 4, 4, 1, (4 * 4), 1, (DDS_CAPS_TEXTURE | DDS_CAPS_COMPLEX), (DDS_CAPS2_CUBEMAP | DDS_CAPS2_CUBEMAP_POSITIVEX), - { D3DXERR_INVALIDDATA, }, TRUE, FALSE, (64 * 6) }, + { D3DXERR_INVALIDDATA, }, FALSE, FALSE, (64 * 6) }, };
dds = calloc(1, sizeof(*dds));