Changeset 57638 in webkit
- Timestamp:
- Apr 15, 2010 3:03:31 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r57633 r57638 1 2010-04-15 Bruno Schmidt <bruno.schmidt@gmail.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Null QObjects properties cause Segmentation Fault 6 https://bugs.webkit.org/show_bug.cgi?id=34730 7 8 QObjects exported to the QWebkit javascript with properties that are 9 a null "QObject*" cause Segmentation Fault. 10 11 If an QObject is added to the javascript context and it contains 12 properties of the type QObject* with NULL value, calling the property 13 causes Segmentation Fault. 14 So now the code below properly checks for null pointers: 15 16 * bridge/qt/qt_instance.cpp: 17 (JSC::Bindings::QtInstance::getClass): may return NULL 18 (JSC::Bindings::QtInstance::getMethod): may return jsNull() 19 (JSC::Bindings::QtInstance::stringValue): may return jsNull() 20 (JSC::Bindings::QtInstance::booleanValue): may return false 21 * bridge/qt/qt_runtime.cpp: 22 (JSC::Bindings::convertValueToQVariant): 23 (JSC::Bindings::convertQVariantToValue): May return jsNull on QObjectStar 24 1 25 2010-04-14 Simon Fraser <simon.fraser@apple.com> 2 26 -
trunk/WebCore/bridge/qt/qt_instance.cpp
r57334 r57638 172 172 Class* QtInstance::getClass() const 173 173 { 174 if (!m_object) 175 return 0; 174 176 if (!m_class) 175 177 m_class = QtClass::classForObject(m_object); … … 239 241 JSValue QtInstance::getMethod(ExecState* exec, const Identifier& propertyName) 240 242 { 241 MethodList methodList = getClass()->methodsNamed(propertyName, this); 243 if (!getClass()) 244 return jsNull(); 245 MethodList methodList = m_class->methodsNamed(propertyName, this); 242 246 return new (exec) RuntimeMethod(exec, propertyName, methodList); 243 247 } … … 260 264 JSValue QtInstance::stringValue(ExecState* exec) const 261 265 { 266 QObject* obj = getObject(); 267 if (!obj) 268 return jsNull(); 269 262 270 // Hmm.. see if there is a toString defined 263 271 QByteArray buf; 264 272 bool useDefault = true; 265 273 getClass(); 266 QObject* obj = getObject(); 267 if (m_class && obj) { 274 if (m_class) { 268 275 // Cheat and don't use the full name resolution 269 276 int index = obj->metaObject()->indexOfMethod("toString()"); … … 310 317 { 311 318 // ECMA 9.2 312 return jsBoolean( true);319 return jsBoolean(getObject()); 313 320 } 314 321 -
trunk/WebCore/bridge/qt/qt_runtime.cpp
r55837 r57638 333 333 } 334 334 335 case QMetaType::QVariantMap: 335 case QMetaType::QVariantMap: 336 336 if (type == Object || type == Array || type == RTArray) { 337 337 // Enumerate the contents of the object … … 872 872 if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) { 873 873 QObject* obj = variant.value<QObject*>(); 874 if (!obj) 875 return jsNull(); 874 876 return QtInstance::getQtInstance(obj, root, QScriptEngine::QtOwnership)->createRuntimeObject(exec); 875 877 } -
trunk/WebKit/qt/ChangeLog
r57631 r57638 1 2010-04-15 Bruno Schmidt <bruno.schmidt@gmail.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Null QObjects properties cause Segmentation Fault 6 https://bugs.webkit.org/show_bug.cgi?id=34730 7 8 QObjects exported to the QWebkit javascript with properties that are 9 a null "QObject*" cause Segmentation Fault. 10 11 If an QObject is added to the javascript context and it contains 12 properties of the type QObject* with NULL value, calling the property 13 causes Segmentation Fault. 14 15 Follow the tests for the corrections done over WebCore. 16 17 * tests/qwebframe/tst_qwebframe.cpp: 18 (MyQObject::MyQObject): init the field m_objectStar 19 (MyQObject::objectStarProperty): read the Object* prop 20 (MyQObject::setObjectStarProperty): write the Object* prop 21 (tst_QWebFrame::getSetStaticProperty): new tests for the new prop 22 1 23 2010-04-14 Luiz Agostini <luiz.agostini@openbossa.org> 2 24 -
trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
r57388 r57638 68 68 Q_PROPERTY(CustomType propWithCustomType READ propWithCustomType WRITE setPropWithCustomType) 69 69 Q_PROPERTY(QWebElement webElementProperty READ webElementProperty WRITE setWebElementProperty) 70 Q_PROPERTY(QObject* objectStarProperty READ objectStarProperty WRITE setObjectStarProperty) 70 71 Q_ENUMS(Policy Strategy) 71 72 Q_FLAGS(Ability) … … 105 106 m_writeOnlyValue(789), 106 107 m_readOnlyValue(987), 108 m_objectStar(0), 107 109 m_qtFunctionInvoked(-1) { } 108 110 … … 197 199 m_customType = c; 198 200 } 201 202 QObject* objectStarProperty() const { 203 return m_objectStar; 204 } 205 206 void setObjectStarProperty(QObject* object) { 207 m_objectStar = object; 208 } 209 199 210 200 211 int qtFunctionInvoked() const { … … 483 494 QWebElement m_webElement; 484 495 CustomType m_customType; 496 QObject* m_objectStar; 485 497 int m_qtFunctionInvoked; 486 498 QVariantList m_actuals; … … 879 891 "myObject.readOnlyProperty == 987"), sTrue); 880 892 QCOMPARE(m_myObject->readOnlyProperty(), 987); 893 894 // QObject* property 895 m_myObject->setObjectStarProperty(0); 896 QCOMPARE(m_myObject->objectStarProperty(), (QObject*)0); 897 QCOMPARE(evalJS("myObject.objectStarProperty == null"), sTrue); 898 QCOMPARE(evalJS("typeof myObject.objectStarProperty"), sObject); 899 QCOMPARE(evalJS("Boolean(myObject.objectStarProperty)"), sFalse); 900 QCOMPARE(evalJS("String(myObject.objectStarProperty) == 'null'"), sTrue); 901 QCOMPARE(evalJS("myObject.objectStarProperty.objectStarProperty"), 902 sUndefined); 903 m_myObject->setObjectStarProperty(this); 904 QCOMPARE(evalJS("myObject.objectStarProperty != null"), sTrue); 905 QCOMPARE(evalJS("typeof myObject.objectStarProperty"), sObject); 906 QCOMPARE(evalJS("Boolean(myObject.objectStarProperty)"), sTrue); 907 QCOMPARE(evalJS("String(myObject.objectStarProperty) != 'null'"), sTrue); 881 908 } 882 909 … … 2841 2868 QTest::qWaitForWindowShown(&view); 2842 2869 #else 2843 QTest::qWait(2000); 2870 QTest::qWait(2000); 2844 2871 #endif 2845 2872
Note: See TracChangeset
for help on using the changeset viewer.