From 51c99e2d56c43ab0d9053b9c8eec200c5238278b Mon Sep 17 00:00:00 2001 From: Christophe Le Roy Date: Sat, 8 Oct 2016 20:37:36 +0200 Subject: [PATCH] parseColorsStream: check RGB components presence Report lines failing to match at least RGB components. --- TileGenerator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TileGenerator.cpp b/TileGenerator.cpp index da6c5ce..acf98ca 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -277,9 +277,13 @@ void TileGenerator::parseColorsStream(std::istream &in) a = 255; t = 0; - sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t); + int read_items = sscanf(line, "%64s %u %u %u %u %u", name, &r, &g, &b, &a, &t); if(strlen(name) == 0) continue; + if(read_items < 4) { + std::cerr << "Unable to parse color '" << line << "'\n"; + continue; + } ColorEntry color = ColorEntry(r, g, b, a, t); m_colorMap[name] = color; }