From e512b25281af5887033dae4bfb1c10c40c18fde7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 28 Mar 2022 20:50:39 +0100 Subject: [PATCH] VST3: Fix for hosts assuming string size includes null byte Signed-off-by: falkTX --- distrho/src/DistrhoPluginVST3.cpp | 4 ++-- distrho/src/DistrhoUIVST3.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/distrho/src/DistrhoPluginVST3.cpp b/distrho/src/DistrhoPluginVST3.cpp index b1ec2ea8..269771f7 100644 --- a/distrho/src/DistrhoPluginVST3.cpp +++ b/distrho/src/DistrhoPluginVST3.cpp @@ -2097,12 +2097,12 @@ public: int16_t* const value16 = (int16_t*)std::malloc(sizeof(int16_t)*(valueLength + 1)); DISTRHO_SAFE_ASSERT_RETURN(value16 != nullptr, V3_NOMEM); - res = v3_cpp_obj(attrs)->get_string(attrs, "key", key16, sizeof(int16_t)*keyLength); + res = v3_cpp_obj(attrs)->get_string(attrs, "key", key16, sizeof(int16_t)*(keyLength+1)); DISTRHO_SAFE_ASSERT_INT2_RETURN(res == V3_OK, res, keyLength, res); if (valueLength != 0) { - res = v3_cpp_obj(attrs)->get_string(attrs, "value", value16, sizeof(int16_t)*valueLength); + res = v3_cpp_obj(attrs)->get_string(attrs, "value", value16, sizeof(int16_t)*(valueLength+1)); DISTRHO_SAFE_ASSERT_INT2_RETURN(res == V3_OK, res, valueLength, res); } diff --git a/distrho/src/DistrhoUIVST3.cpp b/distrho/src/DistrhoUIVST3.cpp index 34cac156..2bd8a7b8 100644 --- a/distrho/src/DistrhoUIVST3.cpp +++ b/distrho/src/DistrhoUIVST3.cpp @@ -573,12 +573,12 @@ public: int16_t* const value16 = (int16_t*)std::malloc(sizeof(int16_t)*(valueLength + 1)); DISTRHO_SAFE_ASSERT_RETURN(value16 != nullptr, V3_NOMEM); - res = v3_cpp_obj(attrs)->get_string(attrs, "key", key16, sizeof(int16_t)*keyLength); + res = v3_cpp_obj(attrs)->get_string(attrs, "key", key16, sizeof(int16_t)*(keyLength+1)); DISTRHO_SAFE_ASSERT_INT2_RETURN(res == V3_OK, res, keyLength, res); if (valueLength != 0) { - res = v3_cpp_obj(attrs)->get_string(attrs, "value", value16, sizeof(int16_t)*valueLength); + res = v3_cpp_obj(attrs)->get_string(attrs, "value", value16, sizeof(int16_t)*(valueLength+1)); DISTRHO_SAFE_ASSERT_INT2_RETURN(res == V3_OK, res, valueLength, res); }