From 99dca62cff3a1c25c3cd4e17de015679810d25e0 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 29 Aug 2016 08:50:11 -0400 Subject: [PATCH] Assert that sampleCount doesn't narrow converting to 3d party types --- src/blockfile/ODPCMAliasBlockFile.cpp | 3 +++ src/blockfile/PCMAliasBlockFile.cpp | 3 +++ src/effects/SBSMSEffect.cpp | 6 +++++- src/ondemand/ODDecodeFlacTask.cpp | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/blockfile/ODPCMAliasBlockFile.cpp b/src/blockfile/ODPCMAliasBlockFile.cpp index 535fea9ca..4c1def4ae 100644 --- a/src/blockfile/ODPCMAliasBlockFile.cpp +++ b/src/blockfile/ODPCMAliasBlockFile.cpp @@ -528,6 +528,9 @@ int ODPCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, mSilentAliasLog=FALSE; + // Third party library has its own type alias, check it + static_assert(sizeof(sampleCount::type) <= sizeof(sf_count_t), + "Type sf_count_t is too narrow to hold a sampleCount"); SFCall(sf_seek, sf.get(), mAliasStart + start, SEEK_SET); wxASSERT(info.channels >= 0); diff --git a/src/blockfile/PCMAliasBlockFile.cpp b/src/blockfile/PCMAliasBlockFile.cpp index 671d90edd..44a08f15e 100644 --- a/src/blockfile/PCMAliasBlockFile.cpp +++ b/src/blockfile/PCMAliasBlockFile.cpp @@ -116,6 +116,9 @@ int PCMAliasBlockFile::ReadData(samplePtr data, sampleFormat format, } mSilentAliasLog=FALSE; + // Third party library has its own type alias, check it + static_assert(sizeof(sampleCount::type) <= sizeof(sf_count_t), + "Type sf_count_t is too narrow to hold a sampleCount"); SFCall(sf_seek, sf.get(), mAliasStart + start, SEEK_SET); wxASSERT(info.channels >= 0); SampleBuffer buffer(len * info.channels, floatSample); diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index dcf9cd83d..6492fd2bc 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -306,11 +306,15 @@ bool EffectSBSMS::Process() outResampleCB = resampleCB; rb.offset = start; rb.end = end; + // Third party library has its own type alias, check it + static_assert(sizeof(sampleCount::type) <= + sizeof(_sbsms_::SampleCountType), + "Type _sbsms_::SampleCountType is too narrow to hold a sampleCount"); rb.iface = std::make_unique(&rateSlide,&pitchSlide, bPitchReferenceInput, samplesToProcess,0, nullptr); - + } else { rb.bPitch = false; diff --git a/src/ondemand/ODDecodeFlacTask.cpp b/src/ondemand/ODDecodeFlacTask.cpp index 32d8da27f..323b54ba3 100644 --- a/src/ondemand/ODDecodeFlacTask.cpp +++ b/src/ondemand/ODDecodeFlacTask.cpp @@ -190,6 +190,10 @@ int ODFlacDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCoun mTargetChannel=channel; + // Third party library has its own type alias, check it + static_assert(sizeof(sampleCount::type) <= + sizeof(FLAC__int64), + "Type FLAC__int64 is too narrow to hold a sampleCount"); if(!mFile->seek_absolute(start)) { mFlacFileLock.Unlock();