From 993c5904e29a7a862d942d07d8f3ec68079147c6 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 19 Aug 2023 23:30:35 -0500 Subject: [PATCH] C140: fix possible crash --- src/engine/platform/c140.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/platform/c140.cpp b/src/engine/platform/c140.cpp index e5de79488..c9e83338c 100644 --- a/src/engine/platform/c140.cpp +++ b/src/engine/platform/c140.cpp @@ -449,6 +449,7 @@ void DivPlatformC140::renderSamples(int sysID) { if (memPos+length>=(getSampleMemCapacity())) { if (s->depth==DIV_SAMPLE_DEPTH_MULAW) { for (unsigned int i=0; i<(getSampleMemCapacity())-memPos; i++) { + if (i>=s->lengthMuLaw) break; unsigned char x=s->dataMuLaw[i]^0xff; if (x&0x80) x^=15; unsigned char c140Mu=(x&0x80)|((x&15)<<3)|((x&0x70)>>4); @@ -461,6 +462,7 @@ void DivPlatformC140::renderSamples(int sysID) { } else { if (s->depth==DIV_SAMPLE_DEPTH_MULAW) { for (unsigned int i=0; i=s->lengthMuLaw) break; unsigned char x=s->dataMuLaw[i]^0xff; if (x&0x80) x^=15; unsigned char c140Mu=(x&0x80)|((x&15)<<3)|((x&0x70)>>4);