From: regehr Date: Thu, 8 Apr 2010 04:21:22 +0000 (+0000) Subject: don't let reading go past the end of the array in the (unlikely but we believe possib... X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=2bba3c3f09b597a543eefa002c1c8789d5db0c89 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 --- 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; } }