[PATCH v2 2/6] d3dx9: Avoid crash in D3DXCheckTextureRequirements() if no replacement format found.
Paul Gofman
gofmanp at gmail.com
Fri Oct 25 12:30:55 CDT 2019
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
dlls/d3dx9_36/texture.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/texture.c b/dlls/d3dx9_36/texture.c
index 12cb2f3983..3f22b050b6 100644
--- a/dlls/d3dx9_36/texture.c
+++ b/dlls/d3dx9_36/texture.c
@@ -337,12 +337,15 @@ HRESULT WINAPI D3DXCheckTextureRequirements(struct IDirect3DDevice9 *device, UIN
else if (h == D3DX_DEFAULT)
h = (width ? w : 256);
- assert(!(fmt->block_width & (fmt->block_width - 1)));
- assert(!(fmt->block_height & (fmt->block_height - 1)));
- if (w & (fmt->block_width - 1))
- w = (w + fmt->block_width) & ~(fmt->block_width - 1);
- if (h & (fmt->block_height - 1))
- h = (h + fmt->block_height) & ~(fmt->block_height - 1);
+ if (fmt)
+ {
+ assert(!(fmt->block_width & (fmt->block_width - 1)));
+ assert(!(fmt->block_height & (fmt->block_height - 1)));
+ if (w & (fmt->block_width - 1))
+ w = (w + fmt->block_width) & ~(fmt->block_width - 1);
+ if (h & (fmt->block_height - 1))
+ h = (h + fmt->block_height) & ~(fmt->block_height - 1);
+ }
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && (!is_pow2(w)))
w = make_pow2(w);
--
2.21.0
More information about the wine-devel
mailing list