winemenubuilder: Fix crash on invalid icon entries.

This commit is contained in:
Indrek Altpere 2014-08-28 19:05:19 +03:00 committed by Alexandre Julliard
parent 3ae113a957
commit c205e6800a
1 changed files with 4 additions and 3 deletions

View File

@ -612,6 +612,7 @@ static int populate_module_icons(HMODULE hModule, GRPICONDIR *grpIconDir, ICONDI
if ((hResData = LoadResource(hModule, hResInfo)))
{
BITMAPINFO *pIcon;
DWORD size = min( grpIconDir->idEntries[i].dwBytesInRes, ((IMAGE_RESOURCE_DATA_ENTRY *)hResInfo)->Size );
if ((pIcon = LockResource(hResData)))
{
iconDirEntries[validEntries].bWidth = grpIconDir->idEntries[i].bWidth;
@ -620,11 +621,11 @@ static int populate_module_icons(HMODULE hModule, GRPICONDIR *grpIconDir, ICONDI
iconDirEntries[validEntries].bReserved = grpIconDir->idEntries[i].bReserved;
iconDirEntries[validEntries].wPlanes = grpIconDir->idEntries[i].wPlanes;
iconDirEntries[validEntries].wBitCount = grpIconDir->idEntries[i].wBitCount;
iconDirEntries[validEntries].dwBytesInRes = grpIconDir->idEntries[i].dwBytesInRes;
iconDirEntries[validEntries].dwBytesInRes = size;
iconDirEntries[validEntries].dwImageOffset = *iconOffset;
validEntries++;
memcpy(&icons[*iconOffset], pIcon, grpIconDir->idEntries[i].dwBytesInRes);
*iconOffset += grpIconDir->idEntries[i].dwBytesInRes;
memcpy(&icons[*iconOffset], pIcon, size);
*iconOffset += size;
}
FreeResource(hResData);
}