From f1a9f40da0e41a926575aa200c79150aa597d1a6 Mon Sep 17 00:00:00 2001 From: oparviai Date: Fri, 27 Feb 2009 17:24:42 +0000 Subject: [PATCH] Check for empty buffer --- source/SoundTouch/FIFOSampleBuffer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/SoundTouch/FIFOSampleBuffer.cpp b/source/SoundTouch/FIFOSampleBuffer.cpp index 0670786..8393f7b 100644 --- a/source/SoundTouch/FIFOSampleBuffer.cpp +++ b/source/SoundTouch/FIFOSampleBuffer.cpp @@ -179,7 +179,10 @@ void FIFOSampleBuffer::ensureCapacity(uint capacityRequirement) } // Align the buffer to begin at 16byte cache line boundary for optimal performance temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16); - memcpy(temp, ptrBegin(), samplesInBuffer * channels * sizeof(SAMPLETYPE)); + if (samplesInBuffer) + { + memcpy(temp, ptrBegin(), samplesInBuffer * channels * sizeof(SAMPLETYPE)); + } delete[] bufferUnaligned; buffer = temp; bufferUnaligned = tempUnaligned;