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()))
cerr << "TCP listen failed.\n";
vector<string *> & args = df::global::ui_sidebar_menus->unk.anon_2;
for (auto it = args.begin(); it != args.end(); )
if (df::global::ui_sidebar_menus)
{
const string & first = **it;
if (first.length() > 0 && first[0] == '+')
vector<string *> & args = df::global::ui_sidebar_menus->unk.anon_2;
for (auto it = args.begin(); it != args.end(); )
{
vector<string> cmd;
for (it++; it != args.end(); it++) {
const string & arg = **it;
if (arg.length() > 0 && arg[0] == '+')
{
break;
const string & first = **it;
if (first.length() > 0 && first[0] == '+')
{
vector<string> cmd;
for (it++; it != args.end(); it++) {
const string & arg = **it;
if (arg.length() > 0 && arg[0] == '+')
{
break;
}
cmd.push_back(arg);
}
cmd.push_back(arg);
}
color_ostream_proxy out(getConsole());
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++)
color_ostream_proxy out(getConsole());
if (runCommand(out, first.substr(1), cmd) != CR_OK)
{
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
{
it++;
else
{
it++;
}
}
}