Capsaicin icon indicating copy to clipboard operation
Capsaicin copied to clipboard

setDebugView(const std::string_view &) malfunctions.

Open Hineven opened this issue 1 year ago • 1 comments

at capsaicin_internal.cpp: 665:

bool CapsaicinInternal::setDebugView(std::string_view const &name) noexcept
{
    auto debugView = std::find_if(
        debug_views_.cbegin(), debug_views_.cend(), [this](auto val) { return debug_view_ == val.first; });
    if (debugView == debug_views_.cend())
    {
        GFX_PRINTLN("Error: Requested invalid debug view: %s", name.data());
        return false;
    }
    debug_view_ = name;
    return true;
}

debug_view_ = name; assumes that name is a string view of a string whose lifetime expands across frames. When a string_view of a temporary string object is passed in (and it is "equal" to one of the strings within the vector debug_views), the function silently fails, debug_view sooner become meaningless and ultimately causes random behavior. I'll suggest a fix about changing debug_view_ = name; to debug_view_ = *debugView; Also, auto debugView = std::find_if(debug_views_.cbegin(), debug_views_.cend(), [this](auto val) { return debug_view_ == val.first; }); seems to not be doing correct validation.

Hineven avatar Apr 19 '24 08:04 Hineven

Thanks, yes thats correct and so weve fixed this internally and should be available in the next release version.

maoliver-amd avatar May 07 '24 14:05 maoliver-amd