From a4065321a0906c755a6ce9d1f49b865c9032322c Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Mon, 24 May 2021 18:57:12 +0200 Subject: [PATCH] msvc: give the temporary buffer a fixed size --- distrho/extra/String.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index a5fdccbe..98beb817 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -656,14 +656,18 @@ public: "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; +#ifndef _MSC_VER const std::size_t kTmpBufSize = std::min(d_nextPowerOf2(static_cast(dataSize/3)), 65536U); +#else + constexpr std::size_t kTmpBufSize = 65536U; +#endif const uchar* bytesToEncode((const uchar*)data); uint i=0, j=0; uint charArray3[3], charArray4[4]; - char* strBuf = (char*)malloc(kTmpBufSize + 1); + char strBuf[kTmpBufSize + 1]; strBuf[kTmpBufSize] = '\0'; std::size_t strBufIndex = 0; @@ -717,8 +721,6 @@ public: ret += strBuf; } - free(strBuf); - return ret; }