Skip to content

Commit

Permalink
ZynAddSubFX: allocate spectrum on heap instead of stack
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tobydox committed Apr 30, 2014
1 parent d58a4d8 commit 9c27956
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/zynaddsubfx/src/Params/PADnoteParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9c27956

Please sign in to comment.