From 2bba3c3f09b597a543eefa002c1c8789d5db0c89 Mon Sep 17 00:00:00 2001 From: regehr Date: Thu, 8 Apr 2010 04:21:22 +0000 Subject: [PATCH] don't let reading go past the end of the array in the (unlikely but we believe possible) case where readDone() and fired() get out of sync --- apps/MultihopOscilloscope/MultihopOscilloscopeC.nc | 3 ++- apps/MultihopOscilloscopeLqi/MultihopOscilloscopeC.nc | 3 ++- apps/Oscilloscope/OscilloscopeC.nc | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc b/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc index 5179b350..a7f39ca6 100644 --- a/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc +++ b/apps/MultihopOscilloscope/MultihopOscilloscopeC.nc @@ -265,7 +265,8 @@ implementation { data = 0xffff; report_problem(); } - local.readings[reading++] = data; + if (reading < NREADINGS) + local.readings[reading++] = data; } diff --git a/apps/MultihopOscilloscopeLqi/MultihopOscilloscopeC.nc b/apps/MultihopOscilloscopeLqi/MultihopOscilloscopeC.nc index 17edb6b7..52354462 100644 --- a/apps/MultihopOscilloscopeLqi/MultihopOscilloscopeC.nc +++ b/apps/MultihopOscilloscopeLqi/MultihopOscilloscopeC.nc @@ -267,7 +267,8 @@ implementation { data = 0xffff; report_problem(); } - local.readings[reading++] = data; + if (reading < NREADINGS) + local.readings[reading++] = data; } diff --git a/apps/Oscilloscope/OscilloscopeC.nc b/apps/Oscilloscope/OscilloscopeC.nc index c4e0a1c0..3003b594 100644 --- a/apps/Oscilloscope/OscilloscopeC.nc +++ b/apps/Oscilloscope/OscilloscopeC.nc @@ -136,6 +136,7 @@ implementation data = 0xffff; report_problem(); } - local.readings[reading++] = data; + if (reading < NREADINGS) + local.readings[reading++] = data; } } -- 2.39.2