mirror of https://github.com/axmolengine/axmol.git
deal the length problem!
This commit is contained in:
parent
d62e3762d2
commit
eb89efe510
|
@ -165,7 +165,9 @@ std::string BundleReader::readString()
|
|||
}
|
||||
|
||||
std::string str;
|
||||
if (length > 0)
|
||||
|
||||
ssize_t validLength = _length - _position;
|
||||
if (length > 0 && length <= validLength)
|
||||
{
|
||||
str.resize(length);
|
||||
if (read(&str[0], 1, length) != length)
|
||||
|
@ -173,6 +175,7 @@ std::string BundleReader::readString()
|
|||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue