From ae744c8b78a78a21cd44e10b65a600ff0c07d250 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sat, 12 May 2012 18:14:29 +0200 Subject: [PATCH] RPC console: don't crash on invalid input exception --- src/qt/rpcconsole.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 0f7828854..33b09952b 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -55,19 +55,26 @@ void RPCExecutor::start() void RPCExecutor::request(const QString &command) { // Parse shell-like command line into separate arguments - boost::escaped_list_separator els('\\',' ','\"'); - std::string strCommand = command.toStdString(); - boost::tokenizer > tok(strCommand, els); - std::string strMethod; std::vector strParams; - int n = 0; - for(boost::tokenizer >::iterator beg=tok.begin(); beg!=tok.end();++beg,++n) + try { + boost::escaped_list_separator els('\\',' ','\"'); + std::string strCommand = command.toStdString(); + boost::tokenizer > tok(strCommand, els); + + int n = 0; + for(boost::tokenizer >::iterator beg=tok.begin(); beg!=tok.end();++beg,++n) + { + if(n == 0) // First parameter is the command + strMethod = *beg; + else + strParams.push_back(*beg); + } + } + catch(boost::escaped_list_error &e) { - if(n == 0) // First parameter is the command - strMethod = *beg; - else - strParams.push_back(*beg); + emit reply(RPCConsole::CMD_ERROR, QString("Parse error")); + return; } try {