From d02698a6dedc63cd0e1be40b994aecf559a4e395 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 11 Nov 2015 09:30:15 -0800 Subject: [PATCH] Apparent bug where min/max aren't initialized from value inside the buffer bounds. The fix is less than ideal, it assumes that an incoming buffer length is always >= 1. --- firmware/baseband/rssi_stats_collector.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/firmware/baseband/rssi_stats_collector.hpp b/firmware/baseband/rssi_stats_collector.hpp index c89f3e17..6ab945bf 100644 --- a/firmware/baseband/rssi_stats_collector.hpp +++ b/firmware/baseband/rssi_stats_collector.hpp @@ -37,6 +37,12 @@ public: return; } + if( statistics.count == 0 ) { + const auto value_0 = *p; + statistics.min = value_0; + statistics.max = value_0; + } + const auto end = &p[buffer.count]; while(p < end) { const uint32_t value = *(p++); @@ -58,9 +64,6 @@ public: callback(statistics); statistics.accumulator = 0; statistics.count = 0; - const auto value_0 = *p; - statistics.min = value_0; - statistics.max = value_0; } }