From 0e91c8614f5d219b20082b826e7013247b0146af Mon Sep 17 00:00:00 2001 From: Adam Stark Date: Sun, 17 Jan 2021 22:54:59 +0000 Subject: [PATCH] Fix bug in last check for out of range in file data --- AudioFile.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AudioFile.h b/AudioFile.h index badd70f..8b3a27a 100644 --- a/AudioFile.h +++ b/AudioFile.h @@ -564,7 +564,7 @@ bool AudioFile::decodeWaveFile (std::vector& fileData) { int sampleIndex = samplesStartIndex + (numBytesPerBlock * i) + channel * numBytesPerSample; - if ((sampleIndex + (bitDepth / 8)) >= fileData.size()) + if ((sampleIndex + (bitDepth / 8) - 1) >= fileData.size()) { reportError ("ERROR: read file error as the metadata indicates more samples than there are in the file data"); return false; @@ -708,7 +708,7 @@ bool AudioFile::decodeAiffFile (std::vector& fileData) { int sampleIndex = samplesStartIndex + (numBytesPerFrame * i) + channel * numBytesPerSample; - if ((sampleIndex + (bitDepth / 8)) >= fileData.size()) + if ((sampleIndex + (bitDepth / 8) - 1) >= fileData.size()) { reportError ("ERROR: read file error as the metadata indicates more samples than there are in the file data"); return false;