steinbergmedia / vst3sdk

VST 3 Plug-In SDK
Other
1.59k stars 162 forks source link

Validator/testsuite issues #36

Closed m-hilgendorf closed 5 years ago

m-hilgendorf commented 5 years ago

The following code can cause stack overflows on Linux with both clang/gcc when printing to stdout from inside a plugin (for debugging purposes)

std::u16string printf (const char8* format, ...)
{
    using VST3::StringConvert::convert;

    char8 string[1024 * 4]; // <<<<<< offending line

    va_list marker;
    va_start (marker, format);

    vsnprintf (string, kPrintfBufferSize, format, marker);
    return convert (string).data ();
}

Fix:

std::u16string printf (const char8* format, ...)
{
    using VST3::StringConvert::convert;

    std::string string;
    string.reserve(1024 * 4);

    va_list marker;
    va_start (marker, format);

    vsnprintf (&string[0], kPrintfBufferSize, format, marker);
    return convert (string).data ();
}

In /testsuite/busconsistency

    randIndex = rand () % (numBusses);

this generates a number between 0 and RAND_MAX when numBusses == 1. I get that there should be at least one event and one audio bus so this shouldn't be an issue, but when testing other issues it came up.

m-hilgendorf commented 5 years ago

Closing this because I realized it was a problem in my own code, the stack overflow was a false positive.