[solved] Bug in getProgramName() in juce_VSTPluginFormat.cpp?

I happened to come across something that looks like a bug in the line where the dispatch gets called here in getProgramName():

const String getProgramName (int index) override
    if (index >= 0)
        if (index == getCurrentProgram())
            return getCurrentProgramName();

        if (vstEffect != nullptr)
            char nm[264] = { 0 };

            if (dispatch (Vst2::effGetProgramNameIndexed, jlimit (0, getNumPrograms(), index), -1, nm, 0) != 0)
                return String::fromUTF8 (nm).trim();

    return {};

Shouldn’t the upper limit of the jlimit be “getNumPrograms() - 1”?
(setCurrentProgram() seems to do this correctly)

I saw this on master, but I just checked and it’s also on develop.

Yep that looks incorrect (and has been that way ever since the code was written!). I’ve added this change to develop:

1 Like

Yeah, I suppose that code path probably never occurred in practice :slight_smile: