fix crash when converting to BRR with invalid loop end

issue #2671
This commit is contained in:
tildearrow 2025-09-03 03:58:45 -05:00
parent 779a8d8810
commit 91965bca8c
2 changed files with 3 additions and 2 deletions

View file

@ -256,7 +256,7 @@ long brrEncode(short* buf, unsigned char* out, long len, long loopStart, unsigne
total+=9; total+=9;
} }
// encode loop block // encode loop block
if (loopStart>=0) { if (loopStart>=0 && loopStart<len) {
long p=loopStart; long p=loopStart;
for (int i=0; i<17; i++) { for (int i=0; i<17; i++) {
if (p>=len) { if (p>=len) {

View file

@ -1479,7 +1479,8 @@ void DivSample::render(unsigned int formatMask) {
} }
} }
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_BRR)) { // BRR 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; if (!initInternal(DIV_SAMPLE_DEPTH_BRR,sampleCount)) return;
brrEncode(data16,dataBRR,sampleCount,loop?loopStart:-1,brrEmphasis,brrNoFilter); brrEncode(data16,dataBRR,sampleCount,loop?loopStart:-1,brrEmphasis,brrNoFilter);
} }