summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4612bb6)
svn path=/trunk/; revision=20117
IconDIR = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
CloseHandle(hSection);
IconDIR = MapViewOfFile(hSection, FILE_MAP_READ, 0, 0, 0);
CloseHandle(hSection);
- if (IconDIR == NULL || 0 != IconDIR->idReserved
- || (IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
+ if (0 != IconDIR->idReserved ||
+ (IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
+ {
+ UnmapViewOfFile(IconDIR);
+ return NULL;
+ }
+
/*
* Get a handle to the screen dc, the icon we create is going to be
* compatable with it.
/*
* Get a handle to the screen dc, the icon we create is going to be
* compatable with it.
if (!dirEntry)
{
UnmapViewOfFile(IconDIR);
if (!dirEntry)
{
UnmapViewOfFile(IconDIR);
}
SafeIconImage = RtlAllocateHeap(GetProcessHeap(), 0, dirEntry->dwBytesInRes);
}
SafeIconImage = RtlAllocateHeap(GetProcessHeap(), 0, dirEntry->dwBytesInRes);
+ if (SafeIconImage == NULL)
+ {
+ UnmapViewOfFile(IconDIR);
+ return NULL;
+ }
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
+ UnmapViewOfFile(IconDIR);
/* at this point we have a copy of the icon image to play with */
/* at this point we have a copy of the icon image to play with */
0,
NULL);
if (hFile == NULL)
0,
NULL);
if (hFile == NULL)
hSection = CreateFileMappingW(hFile,
NULL,
hSection = CreateFileMappingW(hFile,
NULL,
- {
- CloseHandle(hFile);
- return(NULL);
- }
IconDIR = MapViewOfFile(hSection,
FILE_MAP_READ,
0,
0,
0);
IconDIR = MapViewOfFile(hSection,
FILE_MAP_READ,
0,
0,
0);
-
- if (IconDIR == NULL || 0 != IconDIR->idReserved
- || (IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
- {
- CloseHandle(hFile);
- CloseHandle(hSection);
- return(NULL);
- }
+ CloseHandle(hSection);
+ if (IconDIR == NULL)
+ {
+ return NULL;
+ }
+
+ if (0 != IconDIR->idReserved ||
+ (IMAGE_ICON != IconDIR->idType && IMAGE_CURSOR != IconDIR->idType))
+ {
+ UnmapViewOfFile(IconDIR);
+ return NULL;
+ }
//pick the best size.
dirEntry = (CURSORICONDIRENTRY *) CURSORICON_FindBestIcon( IconDIR, width, height, 1);
//pick the best size.
dirEntry = (CURSORICONDIRENTRY *) CURSORICON_FindBestIcon( IconDIR, width, height, 1);
- {
- CloseHandle(hFile);
- CloseHandle(hSection);
- UnmapViewOfFile(IconDIR);
- return(NULL);
- }
+ {
+ UnmapViewOfFile(IconDIR);
+ return NULL;
+ }
SafeIconImage = RtlAllocateHeap(GetProcessHeap(), 0, dirEntry->dwBytesInRes);
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
SafeIconImage = RtlAllocateHeap(GetProcessHeap(), 0, dirEntry->dwBytesInRes);
memcpy(SafeIconImage, ((PBYTE)IconDIR) + dirEntry->dwImageOffset, dirEntry->dwBytesInRes);
-
- CloseHandle(hFile);
- CloseHandle(hSection);
+ UnmapViewOfFile(IconDIR);
}
//at this point we have a copy of the icon image to play with
}
//at this point we have a copy of the icon image to play with
if (hScreenDc == NULL)
{
if (fuLoad & LR_LOADFROMFILE)
if (hScreenDc == NULL)
{
if (fuLoad & LR_LOADFROMFILE)
- {
- RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
- UnmapViewOfFile(IconDIR);
- }
+ {
+ RtlFreeHeap(GetProcessHeap(), 0, SafeIconImage);
+ }
if ((res = CreateBitmapIndirect(&bm)))
{
char *buf = HeapAlloc(GetProcessHeap(), 0, bm.bmWidthBytes * bm.bmHeight);
if ((res = CreateBitmapIndirect(&bm)))
{
char *buf = HeapAlloc(GetProcessHeap(), 0, bm.bmWidthBytes * bm.bmHeight);
+ if (buf == NULL)
+ {
+ DeleteObject(res);
+ return NULL;
+ }
GetBitmapBits(hnd, bm.bmWidthBytes * bm.bmHeight, buf);
SetBitmapBits(res, bm.bmWidthBytes * bm.bmHeight, buf);
HeapFree(GetProcessHeap(), 0, buf);
GetBitmapBits(hnd, bm.bmWidthBytes * bm.bmHeight, buf);
SetBitmapBits(res, bm.bmWidthBytes * bm.bmHeight, buf);
HeapFree(GetProcessHeap(), 0, buf);