msvfw32: Fix copying of a BITMAPINFO structure (Valgrind).

Signed-off-by: Sven Baars <sven.wine@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sven Baars 2019-06-02 16:21:38 +02:00 committed by Alexandre Julliard
parent e5857da273
commit eb69fa7e73
1 changed files with 23 additions and 3 deletions

View File

@ -1506,6 +1506,28 @@ void VFWAPI ICSeqCompressFrameEnd(PCOMPVARS pc)
clear_compvars(pc); clear_compvars(pc);
} }
static BITMAPINFO *copy_bitmapinfo(const BITMAPINFO *src)
{
int num_colors;
unsigned int size;
BITMAPINFO *dst;
if (src->bmiHeader.biClrUsed)
num_colors = min(src->bmiHeader.biClrUsed, 256);
else
num_colors = src->bmiHeader.biBitCount > 8 ? 0 : 1 << src->bmiHeader.biBitCount;
size = FIELD_OFFSET(BITMAPINFO, bmiColors[num_colors]);
if (src->bmiHeader.biCompression == BI_BITFIELDS)
size += 3 * sizeof(DWORD);
if (!(dst = heap_alloc(size)))
return NULL;
memcpy(dst, src, size);
return dst;
}
/*********************************************************************** /***********************************************************************
* ICSeqCompressFrameStart [MSVFW32.@] * ICSeqCompressFrameStart [MSVFW32.@]
*/ */
@ -1517,11 +1539,9 @@ BOOL VFWAPI ICSeqCompressFrameStart(PCOMPVARS pc, LPBITMAPINFO lpbiIn)
DWORD ret; DWORD ret;
ICCOMPRESS* icComp; ICCOMPRESS* icComp;
if (!(pc->lpbiIn = heap_alloc(sizeof(BITMAPINFO)))) if (!(pc->lpbiIn = copy_bitmapinfo(lpbiIn)))
return FALSE; return FALSE;
*pc->lpbiIn = *lpbiIn;
if (!(pc->lpState = heap_alloc(sizeof(ICCOMPRESS) + sizeof(*icComp->lpckid) + sizeof(*icComp->lpdwFlags)))) if (!(pc->lpState = heap_alloc(sizeof(ICCOMPRESS) + sizeof(*icComp->lpckid) + sizeof(*icComp->lpdwFlags))))
goto error; goto error;