DDraw: Do not let the a surface dimension fall to 0

Stefan Dösinger stefandoesinger at gmx.at
Thu Oct 12 12:37:21 CDT 2006


1 / 2 is 0 in an integer division, an application passing a mipmap count could 
end up with a surface that has a width or height of 0. For example, with = 
16, Height = 4, Mipmapcount 5 would give 16x4, 8x2, 4x1, 2x0, 1x0. This 
should not happen, we want 2x1 and 1x1

-------------- next part --------------
From 6d735935b4bc9ddb3dd13f9883a2b5c79afd2241 Mon Sep 17 00:00:00 2001
From: Stefan Doesinger <stefan at codeweavers.com>
Date: Thu, 12 Oct 2006 19:32:36 +0200
Subject: [PATCH] DDraw: Do not allow the surface dimensions to fall to 0
---
 dlls/ddraw/ddraw.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index fc19b3a..9c7648b 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2414,8 +2414,8 @@ IDirectDrawImpl_CreateSurface(IDirectDra
         if(DDSD->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
         {
             level++;
-            desc2.dwWidth /= 2;
-            desc2.dwHeight /= 2;
+            if(desc2.dwWidth > 1) desc2.dwWidth /= 2;
+            if(desc2.dwHeight > 1) desc2.dwHeight /= 2;
         }
 
         DDOBJ_LOCK(This);
-- 
1.4.1.1



More information about the wine-patches mailing list