Don't access invalid memory for tiny or broken input files.
authorMilian Wolff <mail@milianw.de>
Wed, 24 Feb 2016 01:31:21 +0000 (02:31 +0100)
committerMilian Wolff <mail@milianw.de>
Wed, 24 Feb 2016 01:31:21 +0000 (02:31 +0100)
gui/parser.cpp

index fc24251..1a932b6 100644 (file)
@@ -424,7 +424,7 @@ HistogramData buildSizeHistogram(ParserData& data)
             return lhs.allocations > rhs.allocations;
         });
         // -1 to account for total row
-        for (size_t i = 0; i < size_t(HistogramRow::NUM_COLUMNS - 1); ++i) {
+        for (size_t i = 0; i < min(columnData.size(), size_t(HistogramRow::NUM_COLUMNS - 1)); ++i) {
             const auto& column = columnData[i];
             row.columns[i + 1] = {column.allocations, column.location};
         }