diff --git a/src/engine/brrUtils.c b/src/engine/brrUtils.c index 38073fb4b..ff62e5641 100644 --- a/src/engine/brrUtils.c +++ b/src/engine/brrUtils.c @@ -256,7 +256,7 @@ long brrEncode(short* buf, unsigned char* out, long len, long loopStart, unsigne total+=9; } // encode loop block - if (loopStart>=0) { + if (loopStart>=0 && loopStart=len) { diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index 2f7d50617..054d2bc4e 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -1479,7 +1479,8 @@ void DivSample::render(unsigned int formatMask) { } } if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_BRR)) { // BRR - int sampleCount=loop?loopEnd:samples; + int sampleCount=isLoopable()?loopEnd:samples; + if (sampleCount>(int)samples) sampleCount=samples; if (!initInternal(DIV_SAMPLE_DEPTH_BRR,sampleCount)) return; brrEncode(data16,dataBRR,sampleCount,loop?loopStart:-1,brrEmphasis,brrNoFilter); }