Commit a6f3e4ad authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

winhlp32: Fix memory leak on realloc failure in HLPFILE_RtfAddBitmap (cppcheck).

parent e1f45229
...@@ -966,6 +966,7 @@ static BOOL HLPFILE_RtfAddBitmap(struct RtfData* rd, HLPFILE* file, const BYTE* ...@@ -966,6 +966,7 @@ static BOOL HLPFILE_RtfAddBitmap(struct RtfData* rd, HLPFILE* file, const BYTE*
const BYTE* pict_beg; const BYTE* pict_beg;
BYTE* alloc = NULL; BYTE* alloc = NULL;
BITMAPINFO* bi; BITMAPINFO* bi;
BITMAPINFO* new_bi;
ULONG off, csz; ULONG off, csz;
unsigned nc = 0; unsigned nc = 0;
BOOL clrImportant = FALSE; BOOL clrImportant = FALSE;
...@@ -1013,8 +1014,13 @@ static BOOL HLPFILE_RtfAddBitmap(struct RtfData* rd, HLPFILE* file, const BYTE* ...@@ -1013,8 +1014,13 @@ static BOOL HLPFILE_RtfAddBitmap(struct RtfData* rd, HLPFILE* file, const BYTE*
if (!nc && bi->bmiHeader.biBitCount <= 8) if (!nc && bi->bmiHeader.biBitCount <= 8)
nc = 1 << bi->bmiHeader.biBitCount; nc = 1 << bi->bmiHeader.biBitCount;
bi = realloc(bi, sizeof(*bi) + nc * sizeof(RGBQUAD)); new_bi = realloc(bi, sizeof(*bi) + nc * sizeof(RGBQUAD));
if (!bi) return FALSE; if (!new_bi)
{
free(bi);
return FALSE;
}
bi = new_bi;
for (i = 0; i < nc; i++) for (i = 0; i < nc; i++)
{ {
bi->bmiColors[i].rgbBlue = ptr[0]; bi->bmiColors[i].rgbBlue = ptr[0];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment