Sumandora / FrameworkCSGO

A fully-featured training software for Counter Strike: Global Offensive, made for Linux
GNU General Public License v3.0
10 stars 3 forks source link

Readd xorstr to convar names #11

Closed Jovvik closed 1 year ago

Jovvik commented 1 year ago

conVarMap stored const char* as keys. This caused two issues:

  1. The result of xorstr_ was stored, but the pointer could be invalidated once the call to GetConVar was finished.
  2. 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.

Sumandora commented 1 year ago

Puhh, I feel stupid now