Permalink
Browse files

Stop potential crash by guarding the access to the page.

Based on the work from Shawn Krisman (krisman.shawn@gmail.com).

http://code.google.com/p/phantomjs/issues/detail?id=719
  • Loading branch information...
ariya committed Sep 24, 2012
1 parent 63e06cb commit 8ba3c52d50e8c9ab1e6cc91d99640ad6cff284b1
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/phantom.cpp
View
@@ -315,6 +315,9 @@ QObject* Phantom::createCallback()
void Phantom::loadModule(const QString &moduleSource, const QString &filename)
{
+ if (m_terminated)
+ return;
+
QString scriptSource =
"(function(require, exports, module) {" +
moduleSource +
@@ -328,6 +331,9 @@ void Phantom::loadModule(const QString &moduleSource, const QString &filename)
bool Phantom::injectJs(const QString &jsFilePath)
{
+ if (m_terminated)
+ return false;
+
return Utils::injectJsInFrame(jsFilePath, libraryPath(), m_page->mainFrame());
}

0 comments on commit 8ba3c52

Please sign in to comment.