Hey all,
If constructor of Wt application throws (e.g., std::exception)
and does not catch right on the spot it results in segmentation fault.
Test case and patch in the attachment.
--
// Dmitriy.
#include <Wt/WApplication>
class App : public Wt::WApplication
{
public:
App(const Wt::WEnvironment& env);
};
App::App(const Wt::WEnvironment& env)
: WApplication(env)
{
// At this moment, WApplication object does not created yet,
// but code in src/web/WebRenderer.C at line 273 use it uncoditionally.
// Therefore, program receives signal SIGSEGV if application constructor
// throws, like this:
throw std::runtime_error("Have a nice uptime in production.");
}
Wt::WApplication* createApp(const Wt::WEnvironment& env)
{
return new App(env);
}
int main(int argc, char* argv[])
{
return Wt::WRun(argc, argv, createApp);
}
diff --git a/src/web/WebRenderer.C b/src/web/WebRenderer.C
index 5a2668f..a6f6740 100644
--- a/src/web/WebRenderer.C
+++ b/src/web/WebRenderer.C
@@ -261,7 +261,8 @@ void WebRenderer::serveError(WebResponse& response, const std::string& message,
{
bool js = responseType == Update || responseType == Script;
- if (!js) {
+ WApplication *app = WApplication::instance();
+ if (!js || !app) {
response.setContentType("text/html");
response.out()
<< "<title>Error occurred.</title>"
@@ -270,7 +271,7 @@ void WebRenderer::serveError(WebResponse& response, const std::string& message,
<< std::endl;
} else {
response.out() <<
- wApp->javaScriptClass() << "._p_.quit();"
+ app->javaScriptClass() << "._p_.quit();"
"document.title = 'Error occurred.';"
"document.body.innerHtml='<h2>Error occurred.</h2>' +";
DomElement::jsStringLiteral(response.out(), message, '\'');
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest