Add x range check to avoid data corruption.

This commit is contained in:
Tomonobu Saito 2019-10-04 16:47:31 +09:00
parent eef072234e
commit f9ee74d78e

View File

@ -64,12 +64,11 @@ class RasterGrid
boost::algorithm::trim(buf); boost::algorithm::trim(buf);
std::vector<std::string> result; std::vector<std::string> result;
std::string delim (" \r\n\0"); boost::split(result, buf, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on);
boost::split(result, buf, boost::is_any_of(delim), boost::algorithm::token_compress_on); //boost::split(result, buf, boost::is_any_of(" \r\n\0"));
//boost::split(result, buf, boost::is_any_of(delim));
unsigned int x = 0; unsigned int x = 0;
BOOST_FOREACH(std::string s, result) { BOOST_FOREACH(std::string s, result) {
_data[(y * xdim) + x] = atoi(s.c_str()); if (x < xdim) _data[(y * xdim) + x] = atoi(s.c_str());
++x; ++x;
} }
BOOST_ASSERT(x == xdim); BOOST_ASSERT(x == xdim);