From: <pst...@us...> - 2008-04-02 04:40:11
|
Revision: 386 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=386&view=rev Author: pstieber Date: 2008-04-01 21:40:09 -0700 (Tue, 01 Apr 2008) Log Message: ----------- Added some index checking. Modified Paths: -------------- trunk/jazz/src/Configuration.cpp Modified: trunk/jazz/src/Configuration.cpp =================================================================== --- trunk/jazz/src/Configuration.cpp 2008-04-02 04:31:05 UTC (rev 385) +++ trunk/jazz/src/Configuration.cpp 2008-04-02 04:40:09 UTC (rev 386) @@ -706,46 +706,65 @@ // Voice names if (pVector == &mVoiceNames) { - assert(0 <= VoiceIndex && VoiceIndex < mVoiceNames.size()); + if (VoiceIndex >= 0 && VoiceIndex < mVoiceNames.size()) + { + int Value; + sscanf(buf, " %d %n", &Value, &j); - long val; - sscanf(buf, " %ld %n", &val, &j); - if (gpConfig->GetValue(C_UseTwoCommandBankSelect)) - { - assert(0 <= val && val <= 65536); + if (gpConfig->GetValue(C_UseTwoCommandBankSelect)) + { + assert(0 <= Value && Value <= 65536); + } + else + { + assert(0 <= Value && Value <= 32639); + } + + mVoiceNames[VoiceIndex + 1].second = Value + 1; + + // Remove the off \n. + buf[strlen(buf) - 1] = 0; + + mVoiceNames[VoiceIndex + 1].first = buf + j; + + ++VoiceIndex; } else { - assert(0 <= val && val <= 32639); + cout + << "Voice index \"" << VoiceIndex << "\" out of range." + << endl; } - mVoiceNames[VoiceIndex + 1].second = val + 1; - - buf[strlen(buf) - 1] = 0; // cut off \n - mVoiceNames[VoiceIndex + 1].first = buf + j; - - ++VoiceIndex; } // Drumset names else if (pVector == &mDrumSets) { - long val; - assert(0 <= DrumsetIndex && DrumsetIndex < 129); - sscanf(buf, " %ld %n", &val, &j); - if (gpConfig->GetValue(C_UseTwoCommandBankSelect)) + if (DrumsetIndex >= 0 && DrumsetIndex < 129) { - assert(0 <= val && val <= 65536); + int Value; + sscanf(buf, " %d %n", &Value, &j); + if (gpConfig->GetValue(C_UseTwoCommandBankSelect)) + { + assert(0 <= Value && Value <= 65536); + } + else + { + assert(0 <= Value && Value <= 32639); + } + mDrumSets[DrumsetIndex + 1].second = Value + 1; + + buf[strlen(buf) - 1] = 0; // cut off \n + mDrumSets[DrumsetIndex + 1].first = buf + j; + + ++DrumsetIndex; } else { - assert(0 <= val && val <= 32639); + cout + << "Drumset index \"" << DrumsetIndex << "\" out of range." + << endl; } - mDrumSets[DrumsetIndex + 1].second = val + 1; - - buf[strlen(buf) - 1] = 0; // cut off \n - mDrumSets[DrumsetIndex + 1].first = buf + j; - - ++DrumsetIndex; } // Controller names. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |