From 2739b5af54deb069baa5c96adff4554c731f7ff8 Mon Sep 17 00:00:00 2001 From: Eknous-P Date: Mon, 6 Oct 2025 00:40:18 +0400 Subject: [PATCH] fix sample init size way too big --- src/engine/sample.cpp | 3 ++- src/engine/sample.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index 054d2bc4e..624337a68 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -543,7 +543,7 @@ bool DivSample::saveRaw(const char* path) { } // 16-bit memory is padded to 512, to make things easier for ADPCM-A/B. -bool DivSample::initInternal(DivSampleDepth d, int count) { +bool DivSample::initInternal(DivSampleDepth d, unsigned int count) { logV("initInternal(%d,%d)",(int)d,count); switch (d) { case DIV_SAMPLE_DEPTH_1BIT: // 1-bit @@ -651,6 +651,7 @@ bool DivSample::initInternal(DivSampleDepth d, int count) { } bool DivSample::init(unsigned int count) { + if (count>16777215) return false; if (!initInternal(depth,count)) return false; setSampleCount(count); return true; diff --git a/src/engine/sample.h b/src/engine/sample.h index dfd69b400..c671f95d4 100644 --- a/src/engine/sample.h +++ b/src/engine/sample.h @@ -236,7 +236,7 @@ struct DivSample { * @param count number of samples. * @return whether it was successful. */ - bool initInternal(DivSampleDepth d, int count); + bool initInternal(DivSampleDepth d, unsigned int count); /** * initialize sample data. make sure you have set `depth` before doing so.