Skip to content

Commit 5be7710

Browse files
committed
Fixed the value of bufferIndex, line 173 and following, as previous version caused buffer index to be negative, triggering an assert, and most likely access violations and crashes. The important point is that in C99 the '%' operator is a 'remainder' and not a 'modulo' operator, so counterintuitively enough, it will give a negative results for negative numerators...
1 parent 9369075 commit 5be7710

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Source/Processors/LfpDisplayNode/LfpDisplayNode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ void LfpDisplayNode::handleEvent(int eventType, MidiMessage& event, int sampleNu
171171
// << channelForEventSource[eventSourceNode] << std::endl;
172172
////
173173
int bufferIndex = (displayBufferIndex[channelForEventSource[eventSourceNodeId]] + eventTime - nSamples) % displayBuffer->getNumSamples();
174+
175+
bufferIndex = bufferIndex >= 0 ? bufferIndex :
176+
displayBuffer->getNumSamples() + bufferIndex;
177+
174178

175179
if (eventId == 1)
176180
{

0 commit comments

Comments
 (0)