-
Notifications
You must be signed in to change notification settings - Fork 15
Description
ISSUE
Using the wTrig.getVersion() function as outlined in the WTrigAdvanced.ino example sketch causes an array overrun within the gWTrigVersion char array. This causes your arduino sketch to get stuck in a reset loop within the setup() function.
STEPS TO RECREATE
Run the WTrigAdvanced example file but with an empty loop() function. You will see that the sketch never prints the firmware version, number of tracks, or "WAV Trigger response not available" over the serial monitor and instead gets stuck resetting the setup() function. (the attached .txt sketch can be used to recreate the issue)
WTrigAdvanced(current).txt
PROPOSED FIX
In the wavTrigger.cpp file, modify line 236.
| pDst[++i] = 0; |
Current:
pDst[++i] = 0;
Proposed:
pDst[i] = 0;
The overrun is occurring because when the FOR loop reaches its break condition, i = VERSION_STRING_LEN - 1. This is the maximum boundary of "char gWTrigVersion[VERSION_STRING_LEN]" so incrementing i again before adding the zero character takes it beyond bounds.
From my testing, this proposed fix appears to work well, but this is my first time venturing into .cpp and .h files so please don't take my word for it. Also, sorry if this issue report isn't formatted correctly, I have never submitted one before. Thanks for all of the hard work your done so far on this library!