From 206715d82b6ce87669a7e9c88222657670767c07 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sun, 6 Dec 2009 01:01:27 +0100 Subject: [PATCH] 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 5f241e637478d82c2c64d7d67e8828dde1e39aca) --- plugins/vst_base/remote_vst_plugin.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/vst_base/remote_vst_plugin.cpp b/plugins/vst_base/remote_vst_plugin.cpp index 0f9ba6c23..bfeffb0be 100644 --- a/plugins/vst_base/remote_vst_plugin.cpp +++ b/plugins/vst_base/remote_vst_plugin.cpp @@ -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; }