[PATCH] windows.gaming.input: Fix vector InsertAt / RemoveAt copy sizes.

Rémi Bernon rbernon at codeweavers.com
Fri Mar 18 04:22:27 CDT 2022


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/windows.gaming.input/vector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/windows.gaming.input/vector.c b/dlls/windows.gaming.input/vector.c
index c98c89195d1..db1a9057682 100644
--- a/dlls/windows.gaming.input/vector.c
+++ b/dlls/windows.gaming.input/vector.c
@@ -515,7 +515,7 @@ static HRESULT WINAPI vector_InsertAt( IVector_IInspectable *iface, UINT32 index
         }
     }
 
-    memmove( impl->elements + index + 1, impl->elements + index, impl->size++ * sizeof(*impl->elements) );
+    memmove( impl->elements + index + 1, impl->elements + index, (impl->size++ - index) * sizeof(*impl->elements) );
     IInspectable_AddRef( (impl->elements[index] = value) );
     return S_OK;
 }
@@ -528,7 +528,7 @@ static HRESULT WINAPI vector_RemoveAt( IVector_IInspectable *iface, UINT32 index
 
     if (index >= impl->size) return E_BOUNDS;
     IInspectable_Release( impl->elements[index] );
-    memmove( impl->elements + index, impl->elements + index + 1, --impl->size * sizeof(*impl->elements) );
+    memmove( impl->elements + index, impl->elements + index + 1, (--impl->size - index) * sizeof(*impl->elements) );
     return S_OK;
 }
 
-- 
2.35.1




More information about the wine-devel mailing list