mirror of https://github.com/axmolengine/axmol.git
Merge pull request #1319 from walzer/gles20
fix a potential memory leak in CCTextureCache::addImage.
This commit is contained in:
commit
877fe86675
|
@ -437,8 +437,15 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
|
|||
CCImage image;
|
||||
unsigned long nSize = 0;
|
||||
unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize);
|
||||
CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat));
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
if (! image.initWithImageData((void*)pBuffer, nSize, eImageFormat))
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE_ARRAY(pBuffer);
|
||||
}
|
||||
|
||||
texture = new CCTexture2D();
|
||||
|
||||
|
|
Loading…
Reference in New Issue