diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 12551ad858..7daf06cd58 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -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();