From 4a315cd78a3c97d76ae06e3185ab01a70eb9a1a2 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 26 Nov 2015 14:52:03 +0800 Subject: [PATCH] oleaut32: Grow the marshalling buffer exponentially. Signed-off-by: Dmitry Timoshkov Signed-off-by: Alexandre Julliard --- dlls/oleaut32/tmarshal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/oleaut32/tmarshal.c b/dlls/oleaut32/tmarshal.c index f4ce311f252..5fd1fdd6338 100644 --- a/dlls/oleaut32/tmarshal.c +++ b/dlls/oleaut32/tmarshal.c @@ -79,12 +79,14 @@ xbuf_resize(marshal_state *buf, DWORD newsize) if(buf->base) { + newsize = max(newsize, buf->size * 2); buf->base = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buf->base, newsize); if(!buf->base) return E_OUTOFMEMORY; } else { + newsize = max(newsize, 256); buf->base = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, newsize); if(!buf->base) return E_OUTOFMEMORY; @@ -100,7 +102,7 @@ xbuf_add(marshal_state *buf, const BYTE *stuff, DWORD size) if(buf->size - buf->curoff < size) { - hr = xbuf_resize(buf, buf->size + size + 100); + hr = xbuf_resize(buf, buf->size + size); if(FAILED(hr)) return hr; } memcpy(buf->base+buf->curoff,stuff,size);