From: Torsten Dreyer Date: Mon, 10 Mar 2014 22:40:42 +0000 (+0100) Subject: http property browser: don't crash on invalid nodes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=64c393d0221a0318d43d8b1b4b8eed6f2bd780a1;p=flightgear.git http property browser: don't crash on invalid nodes Don't expect users to always pass valid node names or paths --- diff --git a/src/Network/http/PropertyUriHandler.cxx b/src/Network/http/PropertyUriHandler.cxx index fd45492f9..6d57d0174 100644 --- a/src/Network/http/PropertyUriHandler.cxx +++ b/src/Network/http/PropertyUriHandler.cxx @@ -240,7 +240,12 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp // update leaf string value = request.RequestVariables.get("value"); SG_LOG(SG_NETWORK,SG_INFO, "httpd: setting " << propertyPath << " to '" << value << "'" ); - fgSetString( propertyPath.c_str(), value ); + try { + fgSetString( propertyPath.c_str(), value ); + } + catch( string & s ) { + SG_LOG(SG_NETWORK,SG_ALERT, "httpd: setting " << propertyPath << " to '" << value << "' failed: " << s ); + } } if( request.RequestVariables.get("submit") == "set" ) { @@ -248,7 +253,12 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp if( it->first == "submit" ) continue; string pp = propertyPath + "/" + it->first; SG_LOG(SG_NETWORK,SG_INFO, "httpd: setting " << pp << " to '" << it->second << "'" ); - fgSetString( pp, it->second ); + try { + fgSetString( pp, it->second ); + } + catch( string & s ) { + SG_LOG(SG_NETWORK,SG_ALERT, "httpd: setting " << pp << " to '" << it->second << "' failed: " << s ); + } } } @@ -273,7 +283,13 @@ bool PropertyUriHandler::handleGetRequest( const HTTPRequest & request, HTTPResp DOMNode * body = new DOMNode( "body" ); html->addChild( body ); - SGPropertyNode_ptr node = fgGetNode( string("/") + propertyPath ); + SGPropertyNode_ptr node; + try { + node = fgGetNode( string("/") + propertyPath ); + } + catch( string & s ) { + SG_LOG(SG_NETWORK,SG_ALERT, "httpd: reading '" << propertyPath << "' failed: " << s ); + } if( false == node.valid() ) { DOMNode * headline = new DOMNode( "h3" ); body->addChild( headline );