From 2b1eac92ca3d84864f6a2e1d2c78307c2ec8882d Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Sat, 20 Apr 2013 11:08:02 +0100 Subject: [PATCH] Fix array bound SEGV .. double to int conversion rounded up and caused an array bounds segv. just added 1 to the initial resize of the array to avoid. .. annoying since I performed considerable testing of the metric histogram on Mac, but this crashed almost immediately on Linux. Bah. --- src/PowerHist.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/PowerHist.cpp b/src/PowerHist.cpp index 653b56b82..34774d607 100644 --- a/src/PowerHist.cpp +++ b/src/PowerHist.cpp @@ -636,7 +636,7 @@ PowerHist::setData(QList&results, QString totalMetric, QString d // how big should the array be? double multiplier = pow(10, m->precision()); - int max = 0, min = 0; + double max = 0, min = 0; // LOOP THRU VALUES -- REPEATED WITH CUT AND PASTE BELOW // SO PLEASE MAKE SAME CHANGES TWICE (SORRY) @@ -674,7 +674,8 @@ PowerHist::setData(QList&results, QString totalMetric, QString d // now run thru the data again, but this time // populate the metricArray - metricArray.resize(max-min); + // we add 1 to account for possible rounding up + metricArray.resize(1 + (int)(max)-(int)(min)); metricArray.fill(0); // LOOP THRU VALUES -- REPEATED WITH CUT AND PASTE ABOVE