AudioEffectPitchShift: Prevent negative size memset (GCC warning)

This commit is contained in:
Rémi Verschelde 2024-02-19 00:25:54 +01:00
parent ab4c5a594a
commit 3ba724e715
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 3 deletions

View File

@ -87,8 +87,10 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
double magn, phase, tmp, window, real, imag;
double freqPerBin, expct;
long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
unsigned long fftFrameBufferSize;
/* set up some handy variables */
fftFrameBufferSize = (unsigned long)fftFrameSize*sizeof(float);
fftFrameSize2 = fftFrameSize/2;
stepSize = fftFrameSize/osamp;
freqPerBin = sampleRate/(double)fftFrameSize;
@ -160,8 +162,8 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
/* ***************** PROCESSING ******************* */
/* this does the actual pitch shifting */
memset(gSynMagn, 0, fftFrameSize*sizeof(float));
memset(gSynFreq, 0, fftFrameSize*sizeof(float));
memset(gSynMagn, 0, fftFrameBufferSize);
memset(gSynFreq, 0, fftFrameBufferSize);
for (k = 0; k <= fftFrameSize2; k++) {
index = k*pitchShift;
if (index <= fftFrameSize2) {
@ -214,7 +216,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
}
/* shift accumulator */
memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*sizeof(float));
memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameBufferSize);
/* move input FIFO */
for (k = 0; k < inFifoLatency; k++) { gInFIFO[k] = gInFIFO[k+stepSize];