Fix memory & resource leaks

svn path=/trunk/; revision=53924
This commit is contained in:
Pierre Schweitzer 2011-10-02 12:25:07 +00:00
parent 30b66be3ad
commit e950f52e39

View file

@ -38,11 +38,15 @@ DibLoadImage(LPTSTR lpFilename)
lpBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(DIBITMAP)); lpBitmap = HeapAlloc(GetProcessHeap(), 0, sizeof(DIBITMAP));
if (lpBitmap == NULL) if (lpBitmap == NULL)
{
CloseHandle(hFile);
return NULL; return NULL;
}
lpBitmap->header = HeapAlloc(GetProcessHeap(), 0, dwFileSize); lpBitmap->header = HeapAlloc(GetProcessHeap(), 0, dwFileSize);
if (lpBitmap->header == NULL) if (lpBitmap->header == NULL)
{ {
HeapFree(GetProcessHeap(), 0, lpBitmap);
CloseHandle(hFile); CloseHandle(hFile);
return NULL; return NULL;
} }
@ -56,6 +60,7 @@ DibLoadImage(LPTSTR lpFilename)
(lpBitmap->header->bfSize != dwFileSize)) (lpBitmap->header->bfSize != dwFileSize))
{ {
HeapFree(GetProcessHeap(), 0, lpBitmap->header); HeapFree(GetProcessHeap(), 0, lpBitmap->header);
HeapFree(GetProcessHeap(), 0, lpBitmap);
return NULL; return NULL;
} }