mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
fix: applies PR #650 correctly
instead of passing and `int` to `takeData()` it passes a `ssize_t` preventing a possible stackoverflow certain 64-bit platforms
This commit is contained in:
parent
edc8f6e908
commit
55c576e560
@ -62,6 +62,7 @@ GLuint filter (spAtlasFilter filter) {
|
|||||||
|
|
||||||
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
void _spAtlasPage_createTexture (spAtlasPage* self, const char* path) {
|
||||||
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
|
Texture2D* texture = Director::getInstance()->getTextureCache()->addImage(path);
|
||||||
|
CCASSERT(texture != nullptr, "Invalid image");
|
||||||
texture->retain();
|
texture->retain();
|
||||||
|
|
||||||
Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
|
Texture2D::TexParams textureParams = {filter(self->minFilter), filter(self->magFilter), wrap(self->uWrap), wrap(self->vWrap)};
|
||||||
@ -77,11 +78,12 @@ void _spAtlasPage_disposeTexture (spAtlasPage* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* _spUtil_readFile (const char* path, int* length) {
|
char* _spUtil_readFile (const char* path, int* length) {
|
||||||
Data data = FileUtils::getInstance()->getDataFromFile(
|
Data data = FileUtils::getInstance()->getDataFromFile(FileUtils::getInstance()->fullPathForFilename(path));
|
||||||
FileUtils::getInstance()->fullPathForFilename(path));
|
if (data.isNull()) return 0;
|
||||||
if (data.isNull()) return 0;
|
|
||||||
*length = static_cast<int>(data.getSize());
|
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
||||||
char* bytes = MALLOC(char, *length);
|
ssize_t tmpLen;
|
||||||
memcpy(bytes, data.getBytes(), *length);
|
char *ret = (char*)data.takeBuffer(&tmpLen);
|
||||||
return bytes;
|
*length = static_cast<int>(tmpLen);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user