deal the length problem!

This commit is contained in:
lvlong 2014-09-19 14:30:02 +08:00
parent d62e3762d2
commit eb89efe510
1 changed files with 4 additions and 1 deletions

View File

@ -165,7 +165,9 @@ std::string BundleReader::readString()
} }
std::string str; std::string str;
if (length > 0)
ssize_t validLength = _length - _position;
if (length > 0 && length <= validLength)
{ {
str.resize(length); str.resize(length);
if (read(&str[0], 1, length) != length) if (read(&str[0], 1, length) != length)
@ -173,6 +175,7 @@ std::string BundleReader::readString()
return std::string(); return std::string();
} }
} }
return str; return str;
} }