Henri Verbeet : wined3d: Validate the initial texture data before initialising the texture.

Alexandre Julliard julliard at winehq.org
Tue Oct 23 16:10:01 CDT 2018


Module: wine
Branch: master
Commit: 718f7fd4fd29b82194f33e721c7420e39d5209b0
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=718f7fd4fd29b82194f33e721c7420e39d5209b0

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Oct 23 12:36:37 2018 +0330

wined3d: Validate the initial texture data before initialising the texture.

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

---

 dlls/wined3d/texture.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 15492cd..ecbe94b 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -3568,8 +3568,10 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
         UINT layer_count, UINT level_count, DWORD flags, const struct wined3d_sub_resource_data *data,
         void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
 {
+    unsigned int sub_count = level_count * layer_count;
     const struct wined3d_texture_ops *texture_ops;
     struct wined3d_texture *object;
+    unsigned int i;
     HRESULT hr;
 
     TRACE("device %p, desc %p, layer_count %u, level_count %u, flags %#x, data %p, "
@@ -3630,8 +3632,19 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
             return WINED3DERR_INVALIDCALL;
     }
 
-    if (!(object = heap_alloc_zero(FIELD_OFFSET(struct wined3d_texture,
-            sub_resources[level_count * layer_count]))))
+    if (data)
+    {
+        for (i = 0; i < sub_count; ++i)
+        {
+            if (data[i].data)
+                continue;
+
+            WARN("Invalid sub-resource data specified for sub-resource %u.\n", i);
+            return E_INVALIDARG;
+        }
+    }
+
+    if (!(object = heap_alloc_zero(FIELD_OFFSET(struct wined3d_texture, sub_resources[sub_count]))))
         return E_OUTOFMEMORY;
 
     if (FAILED(hr = wined3d_texture_init(object, desc, layer_count,
@@ -3646,21 +3659,8 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
      * in this case. */
     if (data)
     {
-        unsigned int sub_count = level_count * layer_count;
         unsigned int level, width, height, depth;
         struct wined3d_box box;
-        unsigned int i;
-
-        for (i = 0; i < sub_count; ++i)
-        {
-            if (!data[i].data)
-            {
-                WARN("Invalid sub-resource data specified for sub-resource %u.\n", i);
-                wined3d_texture_cleanup_sync(object);
-                heap_free(object);
-                return E_INVALIDARG;
-            }
-        }
 
         for (i = 0; i < sub_count; ++i)
         {




More information about the wine-cvs mailing list