avifil32: Don't leak the buffer on HeapReAlloc() failure in AVIFILE_ReadBlock().

oldstable
Henri Verbeet 2010-01-04 21:33:14 +01:00 committed by Alexandre Julliard
parent 1fb72a37eb
commit c274d6f06e
1 changed files with 7 additions and 5 deletions

View File

@ -2030,12 +2030,14 @@ static HRESULT AVIFILE_ReadBlock(IAVIStreamImpl *This, DWORD pos,
if (This->lpBuffer == NULL || This->cbBuffer < size) {
DWORD maxSize = max(size, This->sInfo.dwSuggestedBufferSize);
if (This->lpBuffer == NULL)
if (This->lpBuffer == NULL) {
This->lpBuffer = HeapAlloc(GetProcessHeap(), 0, maxSize);
else
This->lpBuffer = HeapReAlloc(GetProcessHeap(), 0, This->lpBuffer, maxSize);
if (This->lpBuffer == NULL)
return AVIERR_MEMORY;
if (!This->lpBuffer) return AVIERR_MEMORY;
} else {
void *new_buffer = HeapReAlloc(GetProcessHeap(), 0, This->lpBuffer, maxSize);
if (!new_buffer) return AVIERR_MEMORY;
This->lpBuffer = new_buffer;
}
This->cbBuffer = maxSize;
}