mirror of https://github.com/axmolengine/axmol.git
Merge pull request #9066 from cpascal/fix_bundlereader
Fixed "warning: bundle reader out of range"
This commit is contained in:
commit
d965062866
|
@ -49,13 +49,16 @@ void BundleReader::init(char* buffer, ssize_t length)
|
||||||
ssize_t BundleReader::read(void* ptr, ssize_t size, ssize_t count)
|
ssize_t BundleReader::read(void* ptr, ssize_t size, ssize_t count)
|
||||||
{
|
{
|
||||||
if (!_buffer || eof())
|
if (!_buffer || eof())
|
||||||
|
{
|
||||||
|
CCLOG("warning: bundle reader out of range");
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t validCount;
|
ssize_t validCount;
|
||||||
ssize_t validLength = _length - _position;
|
ssize_t validLength = _length - _position;
|
||||||
ssize_t needLength = size*count;
|
ssize_t needLength = size*count;
|
||||||
char* ptr1 = (char*)ptr;
|
char* ptr1 = (char*)ptr;
|
||||||
if(validLength <= needLength)
|
if(validLength < needLength)
|
||||||
{
|
{
|
||||||
validCount = validLength/size;
|
validCount = validLength/size;
|
||||||
ssize_t readLength = size*validCount;
|
ssize_t readLength = size*validCount;
|
||||||
|
|
Loading…
Reference in New Issue