=?UTF-8?Q?Ri=C4=8Dardas=20Barkauskas=20?=: dxgi: Avoid division by zero.

Alexandre Julliard julliard at winehq.org
Tue Sep 25 15:13:37 CDT 2012


Module: wine
Branch: master
Commit: 342ce213e6d00949bef65a66b32c131dd3cac3bb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=342ce213e6d00949bef65a66b32c131dd3cac3bb

Author: Ričardas Barkauskas <rbarkauskas at codeweavers.com>
Date:   Mon Sep 24 21:01:44 2012 +0300

dxgi: Avoid division by zero.

Based on patch by Eduard - Gabriel Munteanu.

---

 dlls/dxgi/factory.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index b339d0f..72927c5 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -161,6 +161,14 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_GetWindowAssociation(IWineDXGIFact
     return E_NOTIMPL;
 }
 
+static UINT dxgi_rational_to_uint(const DXGI_RATIONAL *rational)
+{
+    if (rational->Denominator)
+        return rational->Numerator / rational->Denominator;
+    else
+        return rational->Numerator;
+}
+
 static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *iface,
         IUnknown *device, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain)
 {
@@ -218,7 +226,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IWineDXGIFactory *
     wined3d_desc.enable_auto_depth_stencil = FALSE;
     wined3d_desc.auto_depth_stencil_format = 0;
     wined3d_desc.flags = 0; /* WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL? */
-    wined3d_desc.refresh_rate = desc->BufferDesc.RefreshRate.Numerator / desc->BufferDesc.RefreshRate.Denominator;
+    wined3d_desc.refresh_rate = dxgi_rational_to_uint(&desc->BufferDesc.RefreshRate);
     wined3d_desc.swap_interval = WINED3DPRESENT_INTERVAL_DEFAULT;
 
     hr = wined3d_device_init_3d(wined3d_device, &wined3d_desc);




More information about the wine-cvs mailing list