[PATCH v3] quartz: Rewrite add_data with CoTaskMemRealloc and error handling

Alex Henrie alexhenrie24 at gmail.com
Tue Aug 14 10:25:10 CDT 2018


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/quartz/filtermapper.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/dlls/quartz/filtermapper.c b/dlls/quartz/filtermapper.c
index 0d26198637..0a41c7144a 100644
--- a/dlls/quartz/filtermapper.c
+++ b/dlls/quartz/filtermapper.c
@@ -145,11 +145,11 @@ static int add_data(struct Vector * v, const BYTE * pData, int size)
     int index = v->current;
     if (v->current + size > v->capacity)
     {
-        LPBYTE pOldData = v->pData;
-        v->capacity = (v->capacity + size) * 2;
-        v->pData = CoTaskMemAlloc(v->capacity);
-        memcpy(v->pData, pOldData, v->current);
-        CoTaskMemFree(pOldData);
+        int new_capacity = (v->capacity + size) * 2;
+        BYTE *new_data = CoTaskMemRealloc(v->pData, new_capacity);
+        if (!new_data) return -1;
+        v->capacity = new_capacity;
+        v->pData = new_data;
     }
     memcpy(v->pData + v->current, pData, size);
     v->current += size;
-- 
2.18.0




More information about the wine-devel mailing list