Skip to content

Commit

Permalink
Fix bug in last check for out of range in file data
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstark committed Jan 17, 2021
1 parent c9ebb00 commit 0e91c86
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions AudioFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ bool AudioFile<T>::decodeWaveFile (std::vector<uint8_t>& 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;
Expand Down Expand Up @@ -708,7 +708,7 @@ bool AudioFile<T>::decodeAiffFile (std::vector<uint8_t>& 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;
Expand Down

0 comments on commit 0e91c86

Please sign in to comment.