From fce21785c2512f1ed1927df05d80c220a22d3cfd Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 2 Jul 2022 03:19:24 -0700 Subject: [PATCH] [MIDI Input] No longer crash when seeking to the end When seeking to the end of a file, no longer crash due to out of range std::vector access, because it was using at() with an offset of the array size. Instead, offset from the begin() iterator return value, which allows offsetting to end(). Signed-off-by: Christopher Snowhill --- Plugins/MIDI/MIDI/MIDIPlayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/MIDI/MIDI/MIDIPlayer.cpp b/Plugins/MIDI/MIDI/MIDIPlayer.cpp index 2fb094401..7c9846f0e 100644 --- a/Plugins/MIDI/MIDI/MIDIPlayer.cpp +++ b/Plugins/MIDI/MIDI/MIDIPlayer.cpp @@ -266,7 +266,7 @@ void MIDIPlayer::Seek(unsigned long sample) { if(uStreamPosition > stream_start) { filler.resize(uStreamPosition - stream_start); - filler.assign(&mStream.at(stream_start), &mStream.at(uStreamPosition)); + filler.assign(mStream.begin() + stream_start, mStream.begin() + uStreamPosition); unsigned long i, j;