From f40b74787d740458f2ce22acd74ae503fc8f0534 Mon Sep 17 00:00:00 2001 From: Jan Ypma Date: Mon, 28 Mar 2016 16:15:42 +0200 Subject: [PATCH] Fix #380: Limit stack allocation during base64 encoding Some VST plugins want to save a large binary chunk of state. For example, Drumlab inside Kontakt 5 saves 1.5MB of data. We shouldn't allocate that much on the stack. --- source/utils/CarlaString.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/utils/CarlaString.hpp b/source/utils/CarlaString.hpp index 6dd47b3e1..4e7459c72 100644 --- a/source/utils/CarlaString.hpp +++ b/source/utils/CarlaString.hpp @@ -20,6 +20,7 @@ #include "CarlaJuceUtils.hpp" #include "CarlaMathUtils.hpp" +#include // ----------------------------------------------------------------------- // CarlaString class @@ -585,7 +586,7 @@ public: "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; - const std::size_t kTmpBufSize = carla_nextPowerOf2(static_cast(dataSize/3)); + const std::size_t kTmpBufSize = std::min(carla_nextPowerOf2(static_cast(dataSize/3)), 65536U); const uchar* bytesToEncode((const uchar*)data);