ZynAddSubFX: allocate spectrum on heap instead of stack

When loading some presets the PADnoteParameters spectrum size is 524288
or even bigger resulting in a stack allocation of 2 MB or more.
This results in a stack overflow on Win32 and thus crashes LMMS. Fix this
by allocating the spectrum on the heap instead.

Closes #543.
This commit is contained in:
Tobias Doerffel
2014-04-30 15:20:44 +02:00
parent d58a4d8804
commit 9c27956414

View File

@@ -555,7 +555,7 @@ void PADnoteParameters::applyparameters(bool lockmutex)
{
const int samplesize = (((int) 1) << (Pquality.samplesize + 14));
int spectrumsize = samplesize / 2;
REALTYPE spectrum[spectrumsize];
REALTYPE *spectrum = new REALTYPE[spectrumsize];
int profilesize = 512;
REALTYPE profile[profilesize];
@@ -653,6 +653,8 @@ void PADnoteParameters::applyparameters(bool lockmutex)
delete (fft);
deleteFFTFREQS(&fftfreqs);
delete[] spectrum;
//delete the additional samples that might exists and are not useful
if(lockmutex) {
pthread_mutex_lock(mutex);