safeguard: do not read/write 0 bytes (iostream)

This commit is contained in:
Alexei Kasatkin
2014-06-05 23:14:36 +06:00
parent a32116d24c
commit b6787b0014
6 changed files with 61 additions and 18 deletions
+5 -2
View File
@@ -79,8 +79,11 @@ int main(int argc, char *argv[])
restriction_ifstream.read((char *)&usable_restriction_count, sizeof(uint32_t));
restrictions_vector.resize(usable_restriction_count);
restriction_ifstream.read((char *)&(restrictions_vector[0]),
usable_restriction_count * sizeof(TurnRestriction));
if (usable_restriction_count>0)
{
restriction_ifstream.read((char *)&(restrictions_vector[0]),
usable_restriction_count * sizeof(TurnRestriction));
}
restriction_ifstream.close();
std::ifstream input_stream;