Merge pull request #1319 from walzer/gles20

fix a potential memory leak in CCTextureCache::addImage.
This commit is contained in:
Walzer 2012-09-15 06:13:13 -07:00
commit 877fe86675
1 changed files with 9 additions and 2 deletions

View File

@ -437,8 +437,15 @@ CCTexture2D * CCTextureCache::addImage(const char * path)
CCImage image; CCImage image;
unsigned long nSize = 0; unsigned long nSize = 0;
unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize);
CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); if (! image.initWithImageData((void*)pBuffer, nSize, eImageFormat))
CC_SAFE_DELETE_ARRAY(pBuffer); {
CC_SAFE_DELETE_ARRAY(pBuffer);
break;
}
else
{
CC_SAFE_DELETE_ARRAY(pBuffer);
}
texture = new CCTexture2D(); texture = new CCTexture2D();