conVarMap stored const char* as keys. This caused two issues:
The result of xorstr_ was stored, but the pointer could be invalidated once the call to GetConVar was finished.
The comparison of map keys was done as pointers. While that technically works (without xorstr_), it is probably UB.
Even though issue 1. suggests wrapping the result of xorstr_ into a strdup, this doesn't work either because of issue 2.
The simplest solution is to do proper comparison of std::strings. Also, std::unordered_map is usually faster than std::map so I changed that as well.
conVarMap
storedconst char*
as keys. This caused two issues:xorstr_
was stored, but the pointer could be invalidated once the call toGetConVar
was finished.xorstr_
), it is probably UB.Even though issue 1. suggests wrapping the result of
xorstr_
into astrdup
, this doesn't work either because of issue 2. The simplest solution is to do proper comparison ofstd::strings
. Also,std::unordered_map
is usually faster thanstd::map
so I changed that as well.