Skip to content

Commit

Permalink
Merge pull request EsotericSoftware#659 from ricardoquesada/issue_650
Browse files Browse the repository at this point in the history
[cocos2d-x] Apply PR EsotericSoftware#650 correctly
  • Loading branch information
badlogic authored Aug 5, 2016
2 parents d5ba507 + 55c576e commit 2b29f9b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions spine-cocos2dx/src/spine/spine-cocos2dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ GLuint filter (spAtlasFilter filter) {

void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
CCASSERT(texture != nullptr, "Invalid image");
texture->retain();

Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
Expand All @@ -77,11 +78,12 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
}

char* _spUtil_readFile (const char* path, int* length) {
Data data = FileUtils::getInstance()->getDataFromFile(
FileUtils::getInstance()->fullPathForFilename(path));
if (data.isNull()) return 0;
*length = static_cast<int>(data.getSize());
char* bytes = MALLOC(char, *length);
memcpy(bytes, data.getBytes(), *length);
return bytes;
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path));
if (data.isNull()) return 0;

// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
ssize_t tmpLen;
char *ret = (char*)data.takeBuffer(&tmpLen);
*length = static_cast<int>(tmpLen);
return ret;
}

0 comments on commit 2b29f9b

Please sign in to comment.