RemoteVstPlugin: allocate buffer for chunk on heap rather than stack

It's not a good idea to allocate the buffer for VST chunk data on the
stack as chunks might become quite big (several megabytes) and thus
could cause a stack overflow. Fix this by using new/delete.
This commit is contained in:
Tobias Doerffel
2009-12-06 01:01:27 +01:00
parent cef439b1ce
commit 5f241e6374

View File

@@ -813,7 +813,7 @@ void RemoteVstPlugin::saveChunkToFile( const std::string & _file )
void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len )
{
char buf[_len];
char * buf = NULL;
void * chunk = NULL;
// various plugins need this in order to not crash when setting
@@ -823,7 +823,8 @@ void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len )
// allocated buffer big enough?
if( _len > actualLen )
{
// no, manually try our local buffer
// no, then manually allocate a buffer
buf = new char[_len];
chunk = buf;
}
@@ -831,6 +832,8 @@ void RemoteVstPlugin::loadChunkFromFile( const std::string & _file, int _len )
read( fd, chunk, _len );
close( fd );
pluginDispatch( 24, 0, _len, chunk );
delete[] buf;
}