Check for ui_sidebar_menus being null before using it.

develop
Ben Lubar 2015-12-17 10:54:19 -06:00
parent 80ec5ab043
commit 9bccf457c5
1 changed files with 26 additions and 23 deletions

@ -1550,36 +1550,39 @@ bool Core::Init()
if (!server->listen(RemoteClient::GetDefaultPort())) if (!server->listen(RemoteClient::GetDefaultPort()))
cerr << "TCP listen failed.\n"; cerr << "TCP listen failed.\n";
vector<string *> & args = df::global::ui_sidebar_menus->unk.anon_2; if (df::global::ui_sidebar_menus)
for (auto it = args.begin(); it != args.end(); )
{ {
const string & first = **it; vector<string *> & args = df::global::ui_sidebar_menus->unk.anon_2;
if (first.length() > 0 && first[0] == '+') for (auto it = args.begin(); it != args.end(); )
{ {
vector<string> cmd; const string & first = **it;
for (it++; it != args.end(); it++) { if (first.length() > 0 && first[0] == '+')
const string & arg = **it; {
if (arg.length() > 0 && arg[0] == '+') vector<string> cmd;
{ for (it++; it != args.end(); it++) {
break; const string & arg = **it;
if (arg.length() > 0 && arg[0] == '+')
{
break;
}
cmd.push_back(arg);
} }
cmd.push_back(arg);
}
color_ostream_proxy out(getConsole()); color_ostream_proxy out(getConsole());
if (runCommand(out, first.substr(1), cmd) != CR_OK) if (runCommand(out, first.substr(1), cmd) != CR_OK)
{
cerr << "Error running command: " << first.substr(1);
for (auto it2 = cmd.begin(); it2 != cmd.end(); it2++)
{ {
cerr << " " << *it2; cerr << "Error running command: " << first.substr(1);
for (auto it2 = cmd.begin(); it2 != cmd.end(); it2++)
{
cerr << " " << *it2;
}
cerr << "\n";
} }
cerr << "\n";
} }
} else
else {
{ it++;
it++; }
} }
} }