Skip to content

Commit ae744c8

Browse files
committed
RPC console: don't crash on invalid input exception
1 parent c6aa86a commit ae744c8

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/qt/rpcconsole.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,26 @@ void RPCExecutor::start()
5555
void RPCExecutor::request(const QString &command)
5656
{
5757
// Parse shell-like command line into separate arguments
58-
boost::escaped_list_separator<char> els('\\',' ','\"');
59-
std::string strCommand = command.toStdString();
60-
boost::tokenizer<boost::escaped_list_separator<char> > tok(strCommand, els);
61-
6258
std::string strMethod;
6359
std::vector<std::string> strParams;
64-
int n = 0;
65-
for(boost::tokenizer<boost::escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg,++n)
60+
try {
61+
boost::escaped_list_separator<char> els('\\',' ','\"');
62+
std::string strCommand = command.toStdString();
63+
boost::tokenizer<boost::escaped_list_separator<char> > tok(strCommand, els);
64+
65+
int n = 0;
66+
for(boost::tokenizer<boost::escaped_list_separator<char> >::iterator beg=tok.begin(); beg!=tok.end();++beg,++n)
67+
{
68+
if(n == 0) // First parameter is the command
69+
strMethod = *beg;
70+
else
71+
strParams.push_back(*beg);
72+
}
73+
}
74+
catch(boost::escaped_list_error &e)
6675
{
67-
if(n == 0) // First parameter is the command
68-
strMethod = *beg;
69-
else
70-
strParams.push_back(*beg);
76+
emit reply(RPCConsole::CMD_ERROR, QString("Parse error"));
77+
return;
7178
}
7279

7380
try {

0 commit comments

Comments
 (0)