Henri Verbeet : wined3d: Require a valid rectangle pointer if rect_count is non-zero in device_clear_render_targets ().

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 18 08:33:03 CDT 2016


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Mar 17 16:30:02 2016 +0100

wined3d: Require a valid rectangle pointer if rect_count is non-zero in device_clear_render_targets().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d8/device.c    | 6 ++++++
 dlls/d3d9/device.c    | 6 ++++++
 dlls/ddraw/device.c   | 6 ++++++
 dlls/wined3d/device.c | 9 ++++-----
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index c1875bc..1cad4be 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -1332,6 +1332,12 @@ static HRESULT WINAPI d3d8_device_Clear(IDirect3DDevice8 *iface, DWORD rect_coun
     TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
             iface, rect_count, rects, flags, color, z, stencil);
 
+    if (rect_count && !rects)
+    {
+        WARN("count %u with NULL rects.\n", rect_count);
+        rect_count = 0;
+    }
+
     wined3d_mutex_lock();
     hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
     wined3d_mutex_unlock();
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 0ed2aff..09c56db 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -1660,6 +1660,12 @@ static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface, DWORD rect_co
     TRACE("iface %p, rect_count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %u.\n",
             iface, rect_count, rects, flags, color, z, stencil);
 
+    if (rect_count && !rects)
+    {
+        WARN("count %u with NULL rects.\n", rect_count);
+        rect_count = 0;
+    }
+
     wined3d_mutex_lock();
     hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil);
     wined3d_mutex_unlock();
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 2474e49..23c3e32 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -5157,6 +5157,12 @@ static HRESULT d3d_device7_Clear(IDirect3DDevice7 *iface, DWORD count,
     TRACE("iface %p, count %u, rects %p, flags %#x, color 0x%08x, z %.8e, stencil %#x.\n",
             iface, count, rects, flags, color, z, stencil);
 
+    if (count && !rects)
+    {
+        WARN("count %u with NULL rects.\n", count);
+        count = 0;
+    }
+
     wined3d_mutex_lock();
     hr = wined3d_device_clear(This->wined3d_device, count, (RECT *)rects, flags, &c, z, stencil);
     wined3d_mutex_unlock();
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 37d9ee9..e428a79 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -263,7 +263,7 @@ static void prepare_ds_clear(struct wined3d_surface *ds, struct wined3d_context
     {
         /* draw_rect ⊇ current_rect, test if we're doing a full clear. */
 
-        if (!clear_rect)
+        if (!rect_count)
         {
             /* Full clear, modify only. */
             *out_rect = *draw_rect;
@@ -285,13 +285,12 @@ static void prepare_ds_clear(struct wined3d_surface *ds, struct wined3d_context
 }
 
 void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb,
-        UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags, const struct wined3d_color *color,
+        UINT rect_count, const RECT *clear_rect, const RECT *draw_rect, DWORD flags, const struct wined3d_color *color,
         float depth, DWORD stencil)
 {
     struct wined3d_surface *target = rt_count ? wined3d_rendertarget_view_get_surface(fb->render_targets[0]) : NULL;
     struct wined3d_surface *depth_stencil = fb->depth_stencil
             ? wined3d_rendertarget_view_get_surface(fb->depth_stencil) : NULL;
-    const RECT *clear_rect = (rect_count > 0 && rects) ? (const RECT *)rects : NULL;
     const struct wined3d_gl_info *gl_info;
     UINT drawable_width, drawable_height;
     struct wined3d_color corrected_color;
@@ -325,7 +324,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
 
         if (rt && rtv->format->id != WINED3DFMT_NULL)
         {
-            if (flags & WINED3DCLEAR_TARGET && !is_full_clear(target, draw_rect, clear_rect))
+            if (flags & WINED3DCLEAR_TARGET && !is_full_clear(target, draw_rect, rect_count ? clear_rect : NULL))
                 surface_load_location(rt, context, rtv->resource->draw_binding);
             else
                 wined3d_surface_prepare(rt, context, rtv->resource->draw_binding);
@@ -440,7 +439,7 @@ void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, c
         clear_mask = clear_mask | GL_COLOR_BUFFER_BIT;
     }
 
-    if (!clear_rect)
+    if (!rect_count)
     {
         if (render_offscreen)
         {




More information about the wine-cvs mailing list