commit e512b25281af5887033dae4bfb1c10c40c18fde7
parent c3796f9a79d550c0e1b1be3f22635b2c8a23ec28
Author: falkTX <falktx@falktx.com>
Date: Mon, 28 Mar 2022 20:50:12 +0100
VST3: Fix for hosts assuming string size includes null byte
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git 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
@@ -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);
}