mirror of https://github.com/axmolengine/axmol.git
Merge pull request #5010 from boyu0/fix_texture2dtest_crash_bug
closed #3638: Fix Image crashes when load tga file.
This commit is contained in:
commit
3bb1fae660
|
@ -376,7 +376,7 @@ namespace
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Image::Image()
|
||||
: _data(0)
|
||||
: _data(nullptr)
|
||||
, _dataLen(0)
|
||||
, _width(0)
|
||||
, _height(0)
|
||||
|
@ -391,10 +391,7 @@ Image::Image()
|
|||
|
||||
Image::~Image()
|
||||
{
|
||||
if (_data != nullptr)
|
||||
{
|
||||
free(_data);
|
||||
}
|
||||
CC_SAFE_FREE(_data);
|
||||
}
|
||||
|
||||
bool Image::initWithImageFile(const std::string& path)
|
||||
|
@ -1539,7 +1536,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData)
|
|||
|
||||
}while(false);
|
||||
|
||||
if (!ret)
|
||||
if (ret)
|
||||
{
|
||||
const unsigned char tgaSuffix[] = ".tga";
|
||||
for(int i = 0; i < 4; ++i)
|
||||
|
@ -1556,6 +1553,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData)
|
|||
if (tgaData->imageData != nullptr)
|
||||
{
|
||||
free(tgaData->imageData);
|
||||
_data = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue