From 79b418c031b2a022199f277f7cc079075979d263 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 4 Apr 2023 22:20:22 -0500 Subject: [PATCH] SegaPCM: fix possible crash --- src/engine/platform/segapcm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/platform/segapcm.cpp b/src/engine/platform/segapcm.cpp index a4003a2be..37fa9ecab 100644 --- a/src/engine/platform/segapcm.cpp +++ b/src/engine/platform/segapcm.cpp @@ -480,7 +480,11 @@ void DivPlatformSegaPCM::renderSamples(int sysID) { if (memPos>=16777216) break; sampleOffSegaPCM[i]=memPos; for (unsigned int j=0; jdata8[j]+0x80); + if (j>=sample->samples) { + sampleMem[memPos++]=0; + } else { + sampleMem[memPos++]=((unsigned char)sample->data8[j]+0x80); + } sampleEndSegaPCM[i]=((memPos+0xff)>>8)-1; if (memPos>=16777216) break; }