From 2a7d49d50378f333e48d2f26f37e52889ca92aea Mon Sep 17 00:00:00 2001 From: Jason Morrison Date: Sat, 26 Feb 2011 14:22:38 -0500 Subject: [PATCH] Null-terminate the embedded capybara.js resource string --- src/WebPage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/WebPage.cpp b/src/WebPage.cpp index 16e1bcf..cdeb692 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -7,7 +7,11 @@ WebPage::WebPage(QObject *parent) : QWebPage(parent) { connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(injectJavascriptHelpers())); QResource javascript(":/capybara.js"); - m_capybaraJavascript = QString((const char *) javascript.data()); + char * javascriptString = new char[javascript.size() + 1]; + strcpy(javascriptString, (const char *)javascript.data()); + javascriptString[javascript.size()] = 0; + m_capybaraJavascript = javascriptString; + delete javascriptString; } void WebPage::injectJavascriptHelpers() {