From f9ee74d78e599143750ae365b5f268ff07caeeaa Mon Sep 17 00:00:00 2001 From: Tomonobu Saito Date: Fri, 4 Oct 2019 16:47:31 +0900 Subject: [PATCH] Add x range check to avoid data corruption. --- include/extractor/raster_source.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/extractor/raster_source.hpp b/include/extractor/raster_source.hpp index 2ed08345b..633c0c661 100755 --- a/include/extractor/raster_source.hpp +++ b/include/extractor/raster_source.hpp @@ -64,12 +64,11 @@ class RasterGrid boost::algorithm::trim(buf); std::vector result; - std::string delim (" \r\n\0"); - boost::split(result, buf, boost::is_any_of(delim), boost::algorithm::token_compress_on); - //boost::split(result, buf, boost::is_any_of(delim)); + boost::split(result, buf, boost::is_any_of(" \r\n\0"), boost::algorithm::token_compress_on); + //boost::split(result, buf, boost::is_any_of(" \r\n\0")); unsigned int x = 0; 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; } BOOST_ASSERT(x == xdim);