Reviewed by Richard.
[WebKit-https.git] / WebCore / khtml / ecma / kjs_events.cpp
index 8e7cdd92dfef35b19dc6ced0931edf6dbca1b66e..0b71f780c7f8b9c54120a9178ef7d8bf8142cf1e 100644 (file)
@@ -98,12 +98,17 @@ void JSAbstractEventListener::handleEvent(DOM::Event &evt, bool isWindowEvent)
         KJS::Interpreter::lock();
         char *message = exec->exception().toObject(exec).get(exec, messagePropertyName).toString(exec).ascii();
         int lineNumber =  exec->exception().toObject(exec).get(exec, "line").toInt32(exec);
-        UString sourceURL = exec->exception().toObject(exec).get(exec, "sourceURL").toString(exec);
+        QString sourceURL;
+        {
+          // put this in a block to make sure UString is deallocated inside the lock
+          UString uSourceURL = exec->exception().toObject(exec).get(exec, "sourceURL").toString(exec);
+          sourceURL = uSourceURL.qstring();
+        }
         KJS::Interpreter::unlock();
         if (Interpreter::shouldPrintExceptions()) {
            printf("(event handler):%s\n", message);
        }
-        KWQ(part)->addMessageToConsole(message, lineNumber, sourceURL.qstring());
+        KWQ(part)->addMessageToConsole(message, lineNumber, sourceURL);
         exec->clearException();
     }
 #else