LCL: Win32: Prevent memory leak + exception when GlobalAlloc api fails. Leak reported on the forum.

git-svn-id: trunk@56908 -
This commit is contained in:
balazs 2018-01-01 20:47:02 +00:00
parent c038b06190
commit 12997708a7

View File

@ -1472,6 +1472,11 @@ begin
// amount of ALLOC_UNIT number in this structure
maxRects := ALLOC_UNIT;
hData := GlobalAlloc(GMEM_MOVEABLE, sizeof(RGNDATAHEADER) + (sizeof(TRECT) * maxRects));
if hData = 0 then
begin
FreeMem(Data);
Exit;
end;
pData := GlobalLock(hData);
pData^.rdh.dwSize := sizeof(RGNDATAHEADER);
pData^.rdh.iType := RDH_RECTANGLES;