From 4103483b91c139b592bc7d36a3ed7f78c13e896b Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sat, 20 Jun 2020 18:17:29 +0200 Subject: [PATCH 1/2] Fix incorrect bounds check --- indra/newview/rlvenvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/rlvenvironment.cpp b/indra/newview/rlvenvironment.cpp index f305309e0c..94878ab112 100644 --- a/indra/newview/rlvenvironment.cpp +++ b/indra/newview/rlvenvironment.cpp @@ -560,7 +560,7 @@ ERlvCmdRet RlvEnvironment::handleSetFn(const std::string& strRlvOption, const st template<> std::string RlvEnvironment::handleLegacyGetFn(const std::function& getFn, U32 idxComponent) { - if (idxComponent > 2) + if (idxComponent >= 2) return LLStringUtil::null; return std::to_string(getFn(LLEnvironment::instance().getCurrentSky()).mV[idxComponent]); } @@ -583,7 +583,7 @@ std::string RlvEnvironment::handleLegacyGetFn(const std::function ERlvCmdRet RlvEnvironment::handleLegacySetFn(float optionValue, LLVector2 curValue, const std::function& setFn, U32 idxComponent) { - if (idxComponent > 2) + if (idxComponent >= 2) return RLV_RET_FAILED_UNKNOWN; LLSettingsSky::ptr_t pSky = LLEnvironment::instance().getCurrentSky(); From 471c53e87095b25f21515125825a30a4129136f8 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Wed, 15 Jul 2020 23:51:57 +0200 Subject: [PATCH 2/2] [FIXED] Crash on Linux when issuing @setenv_ambientr:=force (legacy handling functions returned a reference to a local variable) --- indra/newview/rlvenvironment.cpp | 6 +++--- indra/newview/rlvenvironment.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indra/newview/rlvenvironment.cpp b/indra/newview/rlvenvironment.cpp index 94878ab112..6b498325d9 100644 --- a/indra/newview/rlvenvironment.cpp +++ b/indra/newview/rlvenvironment.cpp @@ -558,7 +558,7 @@ ERlvCmdRet RlvEnvironment::handleSetFn(const std::string& strRlvOption, const st } template<> -std::string RlvEnvironment::handleLegacyGetFn(const std::function& getFn, U32 idxComponent) +std::string RlvEnvironment::handleLegacyGetFn(const std::function& getFn, U32 idxComponent) { if (idxComponent >= 2) return LLStringUtil::null; @@ -566,7 +566,7 @@ std::string RlvEnvironment::handleLegacyGetFn(const std::function -std::string RlvEnvironment::handleLegacyGetFn(const std::function& getFn, U32 idxComponent) +std::string RlvEnvironment::handleLegacyGetFn(const std::function& getFn, U32 idxComponent) { if ( (idxComponent >= VRED) && (idxComponent <= VBLUE) ) { @@ -672,7 +672,7 @@ void RlvEnvironment::registerSetEnvFn(const std::string& strFnName, const std::f } template -void RlvEnvironment::registerLegacySkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn) +void RlvEnvironment::registerLegacySkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn) { RLV_ASSERT(m_LegacyGetFnLookup.end() == m_LegacyGetFnLookup.find(strFnName)); m_LegacyGetFnLookup.insert(std::make_pair(strFnName, [this, getFn](const std::string& strRlvParam, U32 idxComponent) diff --git a/indra/newview/rlvenvironment.h b/indra/newview/rlvenvironment.h index 0f70e24cae..2d19ab2341 100644 --- a/indra/newview/rlvenvironment.h +++ b/indra/newview/rlvenvironment.h @@ -45,12 +45,12 @@ protected: void registerGetEnvFn(const std::string& strFnName, const std::function& getFn); template void registerSetEnvFn(const std::string& strFnName, const std::function& setFn); template void registerSkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn); - template void registerLegacySkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn); + template void registerLegacySkyFn(const std::string& strFnName, const std::function& getFn, const std::function& setFn); // Command handling helpers template std::string handleGetFn(const std::function& fn); template ERlvCmdRet handleSetFn(const std::string& strRlvOption, const std::function& fn); - template std::string handleLegacyGetFn(const std::function& getFn, U32 idxComponent); + template std::string handleLegacyGetFn(const std::function& getFn, U32 idxComponent); template ERlvCmdRet handleLegacySetFn(float optionValue, T value, const std::function& setFn, U32 idxComponent); /*