From 606afe79e6d471586f87686014a850a1c9e23792 Mon Sep 17 00:00:00 2001 From: spx Date: Sat, 19 Feb 2011 21:30:22 +0000 Subject: [PATCH] Fixed crash when AverageSize= is set in Measure. --- Library/Measure.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Measure.cpp b/Library/Measure.cpp index e2e9a670..253bfeb2 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -447,14 +447,16 @@ bool CMeasure::PostUpdate() { if (m_AverageSize > 0) { - if (!m_AverageValues.empty()) + size_t averageValuesSize = m_AverageValues.size(); + + if (m_AverageSize != averageValuesSize) { m_AverageValues.resize(m_AverageSize, m_Value); + averageValuesSize = m_AverageValues.size(); + m_AveragePos %= averageValuesSize; } m_AverageValues[m_AveragePos] = m_Value; - size_t averageValuesSize = m_AverageValues.size(); - ++m_AveragePos; m_AveragePos %= averageValuesSize;