diff --git a/GeoLib/IO/AsciiRasterInterface.cpp b/GeoLib/IO/AsciiRasterInterface.cpp index 1ca81a2526d..7459ab5f726 100644 --- a/GeoLib/IO/AsciiRasterInterface.cpp +++ b/GeoLib/IO/AsciiRasterInterface.cpp @@ -257,18 +257,17 @@ std::vector readFile(std::istream& in) std::optional> readXyzCoordinates(std::string const& line) { - std::array coords; - if (std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0], &coords[1], - &coords[2]) == 3) - { - return coords; - } - else - { - ERR("Raster::readXyzCoordinates() - Unexpected file format:\n{:s}", - line); + std::array coords = {0, 0, 0}; + if (auto const n = std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0], + &coords[1], &coords[2]); + n != 3) + { + ERR("Raster::readXyzCoordinates() - Read {:d} doubles out of 3 " + "expected from the following line:\n{:s}", + n, line); return std::nullopt; } + return coords; } GeoLib::RasterHeader getXyzHeader(std::vector const& lines)