From 41c855be7c50049291196d56bca68f2f79fb747c Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Wed, 24 Feb 2016 02:31:21 +0100 Subject: [PATCH] Don't access invalid memory for tiny or broken input files. --- gui/parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/parser.cpp b/gui/parser.cpp index fc24251..1a932b6 100644 --- a/gui/parser.cpp +++ b/gui/parser.cpp @@ -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}; } -- 2.7.4