ref: 77f30014a888e20a0940db2c328d935e9e18ec7f
parent: 5bbaed9d9de1fdbbff75a4e6e860b42feca782fe
author: Olav Sørensen <olav.sorensen@live.no>
date: Fri May 12 19:32:29 EDT 2023
>2GB sample load crashfix
--- a/src/pt2_sample_loader.c
+++ b/src/pt2_sample_loader.c
@@ -27,11 +27,11 @@
SAMPLETYPE_FLAC
};
-bool loadRAWSample(FILE *f, int32_t filesize, moduleSample_t *s);
-bool loadIFFSample(FILE *f, int32_t filesize, moduleSample_t *s);
-bool loadAIFFSample(FILE *f, int32_t filesize, moduleSample_t *s);
-bool loadWAVSample(FILE *f, int32_t filesize, moduleSample_t *s);
-bool loadFLACSample(FILE *f, int32_t filesize, moduleSample_t *s);
+bool loadRAWSample(FILE *f, uint32_t filesize, moduleSample_t *s);
+bool loadIFFSample(FILE *f, uint32_t filesize, moduleSample_t *s);
+bool loadAIFFSample(FILE *f, uint32_t filesize, moduleSample_t *s);
+bool loadWAVSample(FILE *f, uint32_t filesize, moduleSample_t *s);
+bool loadFLACSample(FILE *f, uint32_t filesize, moduleSample_t *s);
static void setSampleTextFromFilename(moduleSample_t *s, char *entryName, const char *ext)
{
--- a/src/smploaders/pt2_load_aiff.c
+++ b/src/smploaders/pt2_load_aiff.c
@@ -33,7 +33,7 @@
return (uint32_t)round(dResult);
}
-bool loadAIFFSample(FILE *f, int32_t filesize, moduleSample_t *s)
+bool loadAIFFSample(FILE *f, uint32_t filesize, moduleSample_t *s)
{
uint8_t sampleRateBytes[10];
uint16_t bitDepth, numChannels;
@@ -46,7 +46,7 @@
bool unsigned8bit = false;
fseek(f, 12, SEEK_SET);
- while (!feof(f) && ftell(f) < filesize-12)
+ while (!feof(f) && (uint32_t)ftell(f) < filesize-12)
{
uint32_t blockName, blockSize;
--- a/src/smploaders/pt2_load_flac.c
+++ b/src/smploaders/pt2_load_flac.c
@@ -48,7 +48,7 @@
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data);
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-bool loadFLACSample(FILE *f, int32_t filesize, moduleSample_t *s)
+bool loadFLACSample(FILE *f, uint32_t filesize, moduleSample_t *s)
{
FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new();
if (decoder == NULL)
--- a/src/smploaders/pt2_load_iff.c
+++ b/src/smploaders/pt2_load_iff.c
@@ -14,7 +14,7 @@
#include "../pt2_downsample2x.h"
#include "../pt2_audio.h"
-bool loadIFFSample(FILE *f, int32_t filesize, moduleSample_t *s)
+bool loadIFFSample(FILE *f, uint32_t filesize, moduleSample_t *s)
{
char tmpCharBuf[23];
uint16_t sampleRate;
@@ -33,7 +33,7 @@
uint32_t sampleVolume = 65536; // max volume
fseek(f, 12, SEEK_SET);
- while (!feof(f) && ftell(f) < filesize-12)
+ while (!feof(f) && (uint32_t)ftell(f) < filesize-12)
{
uint32_t blockName, blockSize;
--- a/src/smploaders/pt2_load_raw.c
+++ b/src/smploaders/pt2_load_raw.c
@@ -7,10 +7,10 @@
#include "../pt2_structs.h"
#include "../pt2_replayer.h"
-bool loadRAWSample(FILE *f, int32_t filesize, moduleSample_t *s)
+bool loadRAWSample(FILE *f, uint32_t filesize, moduleSample_t *s)
{
- int32_t sampleLength = filesize;
- if (sampleLength > config.maxSampleLength)
+ uint32_t sampleLength = filesize;
+ if (sampleLength > (uint32_t)config.maxSampleLength)
sampleLength = config.maxSampleLength;
int8_t *smpDataPtr = &song->sampleData[s->offset];
@@ -20,7 +20,7 @@
if (sampleLength & 1)
{
- if (++sampleLength > config.maxSampleLength)
+ if (++sampleLength > (uint32_t)config.maxSampleLength)
sampleLength = config.maxSampleLength;
}
--- a/src/smploaders/pt2_load_wav.c
+++ b/src/smploaders/pt2_load_wav.c
@@ -20,7 +20,7 @@
WAV_FORMAT_IEEE_FLOAT = 0x0003
};
-bool loadWAVSample(FILE *f, int32_t filesize, moduleSample_t *s)
+bool loadWAVSample(FILE *f, uint32_t filesize, moduleSample_t *s)
{
uint16_t audioFormat, numChannels, bitsPerSample;
uint32_t sampleRate;