[1/7] msvfw32: Use a helper to free memory

Bruno Jesus 00cpxxx at gmail.com
Tue Oct 20 01:56:02 CDT 2015


Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>

This sequence of patches fixes all problems from bug
https://bugs.winehq.org/show_bug.cgi?id=27595 (Hyper Cam 2) making the
app run correctly.

The folllowing codecs were tested and work (generate good avi files):
Indeo 4.5
Indeo 5
Xvid 1.3.3
Lagarith 1.3.27
(uncompressed video also tested)
-------------- next part --------------

---
 dlls/msvfw32/msvideo_main.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/dlls/msvfw32/msvideo_main.c b/dlls/msvfw32/msvideo_main.c
index 5aff706..b4c22ae 100644
--- a/dlls/msvfw32/msvideo_main.c
+++ b/dlls/msvfw32/msvideo_main.c
@@ -1401,6 +1401,15 @@ LPVOID VFWAPI ICSeqCompressFrame(PCOMPVARS pc, UINT uiFlags, LPVOID lpBits, BOOL
     return NULL;
 }
 
+static void clear_compvars(PCOMPVARS pc)
+{
+    HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
+    HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
+    HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
+    HeapFree(GetProcessHeap(), 0, pc->lpState);
+    pc->lpbiIn = pc->lpBitsPrev = pc->lpBitsOut = pc->lpState = NULL;
+}
+
 /***********************************************************************
  *      ICSeqCompressFrameEnd   [MSVFW32.@]
  */
@@ -1410,11 +1419,7 @@ void VFWAPI ICSeqCompressFrameEnd(PCOMPVARS pc)
     TRACE("(%p)\n", pc);
     ret = ICSendMessage(pc->hic, ICM_COMPRESS_END, 0, 0);
     TRACE(" -- %x\n", ret);
-    HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
-    HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
-    HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
-    HeapFree(GetProcessHeap(), 0, pc->lpState);
-    pc->lpbiIn = pc->lpBitsPrev = pc->lpBitsOut = pc->lpState = NULL;
+    clear_compvars(pc);
 }
 
 /***********************************************************************
@@ -1474,11 +1479,7 @@ BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn)
        return TRUE;
     }
 error:
-    HeapFree(GetProcessHeap(), 0, pc->lpbiIn);
-    HeapFree(GetProcessHeap(), 0, pc->lpBitsPrev);
-    HeapFree(GetProcessHeap(), 0, pc->lpState);
-    HeapFree(GetProcessHeap(), 0, pc->lpBitsOut);
-    pc->lpBitsPrev = pc->lpbiIn = pc->lpState = pc->lpBitsOut = NULL;
+    clear_compvars(pc);
     return FALSE;
 }
 
-- 
2.1.4



More information about the wine-patches mailing list