Fixed #656: crash on startup

Amiberry would crash on startup if the controller.cfg file contained empty lines
This commit is contained in:
Dimitris Panokostas 2020-06-11 23:40:26 +02:00
parent 6da5e9136a
commit 7a82b8a90b

View file

@ -483,7 +483,7 @@ int find_retroarch(const TCHAR* find_setting, char* retroarch_file, host_input_b
auto tempbutton = -1;
// read each line in
while (std::getline(readFile, line))
while (std::getline(readFile, line) && line.length() > 1)
{
if (strncmp(find_setting, "count_hats", 10) == 0)
{
@ -495,7 +495,7 @@ int find_retroarch(const TCHAR* find_setting, char* retroarch_file, host_input_b
if (param.at(param.length() - 1) == '"')
param.erase(param.length() - 1, 1);
if (param.find("h") == 0)
if (param.find('h') == 0)
{
tempbutton = 1;
break;
@ -545,7 +545,7 @@ bool find_retroarch_polarity(const TCHAR* find_setting, char* retroarch_file)
auto tempbutton = false;
// read each line in
while (std::getline(readFile, line))
while (std::getline(readFile, line) && line.length() > 1)
{
const auto option = line.substr(0, line.find(delimiter));
@ -597,7 +597,7 @@ const TCHAR* find_retroarch_key(const TCHAR* find_setting_prefix, int player, co
}
// read each line in
while (std::getline(read_file, line))
while (std::getline(read_file, line) && line.length() > 1)
{
const auto option = line.substr(0, line.find(delimiter));