From 24703e4cd63401079bb6f3a734c25fadd4ae620d Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Tue, 14 Aug 2018 09:25:10 -0600 Subject: [PATCH] quartz: Rewrite add_data with CoTaskMemRealloc and error handling. Signed-off-by: Alex Henrie Signed-off-by: Alexandre Julliard --- 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 0d261986373..0a41c7144ac 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;