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));
if (lpBitmap == NULL)
{
CloseHandle(hFile);
return NULL;
}
lpBitmap->header = HeapAlloc(GetProcessHeap(), 0, dwFileSize);
if (lpBitmap->header == NULL)
{
HeapFree(GetProcessHeap(), 0, lpBitmap);
CloseHandle(hFile);
return NULL;
}
@ -56,6 +60,7 @@ DibLoadImage(LPTSTR lpFilename)
(lpBitmap->header->bfSize != dwFileSize))
{
HeapFree(GetProcessHeap(), 0, lpBitmap->header);
HeapFree(GetProcessHeap(), 0, lpBitmap);
return NULL;
}