Henri Verbeet : avifil32: Don't leak the buffer on HeapReAlloc() failure in AVIFILE_AddFrame().
Alexandre Julliard
julliard at winehq.org
Wed Jan 6 13:00:56 CST 2010
Module: wine
Branch: master
Commit: 7ab71039465505db5d68b830da1648f87e7bdb88
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7ab71039465505db5d68b830da1648f87e7bdb88
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Tue Jan 5 21:29:02 2010 +0100
avifil32: Don't leak the buffer on HeapReAlloc() failure in AVIFILE_AddFrame().
Perhaps the code should also just double the buffer. I can send another patch
for that if needed.
---
dlls/avifil32/avifile.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index ea6d6b1..57ebb11 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -1383,16 +1383,20 @@ static HRESULT AVIFILE_AddFrame(IAVIStreamImpl *This, DWORD ckid, DWORD size, DW
}
if (This->idxFmtChanges == NULL || This->nIdxFmtChanges <= This->sInfo.dwFormatChangeCount) {
- This->nIdxFmtChanges += 16;
- if (This->idxFmtChanges == NULL)
- This->idxFmtChanges =
- HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->nIdxFmtChanges * sizeof(AVIINDEXENTRY));
- else
+ DWORD new_count = This->nIdxFmtChanges + 16;
+ void *new_buffer;
+
+ if (This->idxFmtChanges == NULL) {
This->idxFmtChanges =
- HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->idxFmtChanges,
- This->nIdxFmtChanges * sizeof(AVIINDEXENTRY));
- if (This->idxFmtChanges == NULL)
- return AVIERR_MEMORY;
+ HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * sizeof(AVIINDEXENTRY));
+ if (!This->idxFmtChanges) return AVIERR_MEMORY;
+ } else {
+ new_buffer = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->idxFmtChanges,
+ new_count * sizeof(AVIINDEXENTRY));
+ if (!new_buffer) return AVIERR_MEMORY;
+ This->idxFmtChanges = new_buffer;
+ }
+ This->nIdxFmtChanges = new_count;
}
This->sInfo.dwFlags |= AVISTREAMINFO_FORMATCHANGES;
More information about the wine-cvs
mailing list