diff --git a/src/core/Sample.cpp b/src/core/Sample.cpp index 26d5edbf6..03abc6ff7 100644 --- a/src/core/Sample.cpp +++ b/src/core/Sample.cpp @@ -27,6 +27,7 @@ #include #include #include +#include "ArrayVector.h" namespace lmms { @@ -384,7 +385,8 @@ auto Sample::playSampleRange(PlaybackState* state, sampleFrame* dst, int numFram numFrames / resampleRatio + (resampleRatio != 1.0f ? s_interpolationMargins[state->m_interpolationMode] : 0), m_endFrame - state->m_frameIndex); - auto buffer = std::vector(numFramesToCopy); + if (numFramesToCopy > 4096) { return false; } + auto buffer = ArrayVector(numFramesToCopy); copyBufferForward(buffer.data(), state->m_frameIndex, numFramesToCopy); auto resample @@ -402,7 +404,8 @@ auto Sample::playSampleRangeLoop(PlaybackState* state, sampleFrame* dst, int num const auto totalFramesToCopy = static_cast( numFrames / resampleRatio + (resampleRatio != 1.0f ? s_interpolationMargins[state->m_interpolationMode] : 0)); - auto buffer = std::vector(totalFramesToCopy); + if (totalFramesToCopy > 4096) { return false; } + auto buffer = ArrayVector(totalFramesToCopy); auto numFramesCopied = 0; while (numFramesCopied != totalFramesToCopy) @@ -437,7 +440,8 @@ auto Sample::playSampleRangePingPong(PlaybackState* state, sampleFrame* dst, int const auto totalFramesToCopy = static_cast( numFrames / resampleRatio + (resampleRatio != 1.0f ? s_interpolationMargins[state->m_interpolationMode] : 0)); - auto buffer = std::vector(totalFramesToCopy); + if (totalFramesToCopy > 4096) { return false; } + auto buffer = ArrayVector(totalFramesToCopy); auto numFramesCopied = 0; while (numFramesCopied != totalFramesToCopy)