IniFile: Prevent potential out-of-bounds access in ParseLine()

While current usages of ParseLine aren't problematic, this is still a
public function that can be used for other purposes. Essentially makes
the function handle potential external inputs a little nicer.
This commit is contained in:
Lioncash 2019-05-22 21:09:09 -04:00
parent e2c769a9c5
commit 2ae370fc37

View file

@ -20,7 +20,7 @@
void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut) void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut)
{ {
if (line[0] == '#') if (line.empty() || line.front() == '#')
return; return;
size_t firstEquals = line.find('='); size_t firstEquals = line.find('=');