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.
(cherry picked from commit 5f241e6374)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user