mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-11-26 11:49:19 +00:00
defensive attempt to avoid buffer overruns
This commit is contained in:
parent
fc805b57e2
commit
c07c24d064
@ -124,8 +124,10 @@ void TeensySpeaker::toggle(int64_t c)
|
|||||||
if (newIdx > bufIdx) {
|
if (newIdx > bufIdx) {
|
||||||
long count = (long)newIdx - bufIdx;
|
long count = (long)newIdx - bufIdx;
|
||||||
for (long i=0; i<count; i++) {
|
for (long i=0; i<count; i++) {
|
||||||
|
if (bufIdx+i+1 < sizeof(soundBuf)/sizeof(short)) {
|
||||||
soundBuf[bufIdx+i] = toggleState ? HIGHVAL : LOWVAL;
|
soundBuf[bufIdx+i] = toggleState ? HIGHVAL : LOWVAL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
bufIdx = newIdx;
|
bufIdx = newIdx;
|
||||||
}
|
}
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
Loading…
Reference in New Issue
Block a user