Skip to content

Commit

Permalink
DuiSystem的LoadImageFile等函数增加容错性处理,如果文件加载失败,会把传入的指针设置为空,避免调用方没有初始化指针,加…
Browse files Browse the repository at this point in the history
…载失败的情况下又使用指针导致异常。
  • Loading branch information
blueantst committed Feb 4, 2017
1 parent a21a74e commit 439d788
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions DuiVision/source/DuiSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ BOOL DuiSystem::LoadImageFile(CString strFileName, BOOL useEmbeddedColorManageme
//delete[] pByte;
}else
{
pImage = NULL;
return FALSE;
}
}
Expand All @@ -810,6 +811,7 @@ BOOL DuiSystem::LoadImageFile(CString strFileName, BOOL useEmbeddedColorManageme
}else
{
// 文件不存在
pImage = NULL;
return FALSE;
}
}
Expand Down Expand Up @@ -893,6 +895,7 @@ BOOL DuiSystem::LoadIconFile(CString strFileName, HICON& hIcon)
//delete[] pByte;
}else
{
hIcon = NULL;
return FALSE;
}
}
Expand All @@ -908,6 +911,7 @@ BOOL DuiSystem::LoadIconFile(CString strFileName, HICON& hIcon)
}else
{
// 文件不存在
hIcon = NULL;
return FALSE;
}
}
Expand Down Expand Up @@ -940,6 +944,7 @@ BOOL DuiSystem::LoadFileToBuffer(CString strFileName, BYTE*& pBuffer, DWORD& dwS
}
if(pByte == NULL)
{
pBuffer = NULL;
return FALSE;
}
}
Expand All @@ -955,6 +960,7 @@ BOOL DuiSystem::LoadFileToBuffer(CString strFileName, BYTE*& pBuffer, DWORD& dwS
}else
{
// 文件不存在
pBuffer = NULL;
return FALSE;
}
}
Expand All @@ -966,6 +972,7 @@ BOOL DuiSystem::LoadFileToBuffer(CString strFileName, BYTE*& pBuffer, DWORD& dwS
// 打开文件
if ( !file.Open( _strFileName, CFile::modeRead ) )
{
pBuffer = NULL;
return FALSE;
}
dwSize = (DWORD)file.GetLength();
Expand Down

0 comments on commit 439d788

Please sign in to comment.