mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[cocos2d-x] Closes #650, don't deep copy data read from file on cocos2d-x 3.12+
This commit is contained in:
parent
2b29f9b5b6
commit
819bb4cf0c
@ -82,8 +82,15 @@ char* _spUtil_readFile (const char* path, int* length) {
|
||||
if (data.isNull()) return 0;
|
||||
|
||||
// avoid buffer overflow (int is shorter than ssize_t in certain platforms)
|
||||
#if COCOS2D_VERSION >= 0x00031200
|
||||
ssize_t tmpLen;
|
||||
char *ret = (char*)data.takeBuffer(&tmpLen);
|
||||
*length = static_cast<int>(tmpLen);
|
||||
return ret;
|
||||
#else
|
||||
*length = static_cast<int>(data.getSize());
|
||||
char* bytes = MALLOC(char, *length);
|
||||
memcpy(bytes, data.getBytes(), *length);
|
||||
return bytes;
|
||||
#endif
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user