Matteo Bruni : d3dx9: Make the assert() in regstore_set_values() a bit more strict.

Alexandre Julliard julliard at winehq.org
Wed Jun 21 16:43:44 CDT 2017


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

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Wed Jun 21 21:54:21 2017 +0200

d3dx9: Make the assert() in regstore_set_values() a bit more strict.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dx9_36/preshader.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index 2785ca3..7ca0c8f 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -372,14 +372,17 @@ static void regstore_set_modified(struct d3dx_regstore *rs, unsigned int table,
 static void regstore_set_values(struct d3dx_regstore *rs, unsigned int table, const void *data,
         unsigned int start_offset, unsigned int count)
 {
-    void *out;
+    BYTE *dst = rs->tables[table];
+    const BYTE *src = data;
+    unsigned int size;
 
     if (!count)
         return;
 
-    out = (BYTE *)rs->tables[table] + start_offset * table_info[table].component_size;
-    assert(data != out);
-    memcpy(out, data, count * table_info[table].component_size);
+    dst += start_offset * table_info[table].component_size;
+    size = count * table_info[table].component_size;
+    assert((src < dst && size <= dst - src) || (src > dst && size <= src - dst));
+    memcpy(dst, src, size);
     regstore_set_modified(rs, table, start_offset, count);
 }
 




More information about the wine-cvs mailing list