summaryrefslogtreecommitdiffstats
path: root/tests/auto/qscriptengine
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-10-29 13:03:38 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-10-29 14:06:19 (GMT)
commitbf8a9dc1248083dfb0ce5599b11af1727d349631 (patch)
treeca22f7e5dd0fa88e6f0a6411f7170c28eda7a3a1 /tests/auto/qscriptengine
parent0c643b179c5154c50b61dba421016b7b48794720 (diff)
downloadQt-bf8a9dc1248083dfb0ce5599b11af1727d349631.zip
Qt-bf8a9dc1248083dfb0ce5599b11af1727d349631.tar.gz
Qt-bf8a9dc1248083dfb0ce5599b11af1727d349631.tar.bz2
Don't crash when null-pointer is passed to qScriptValueFromValue()
qScriptValueFromValue_helper() (or rather, QScriptEnginePrivate::create()) will fall back to wrapping the value using newVariant(), so there is no reason for the QVariant specialization to check the return value. (In particular, if the return value was invalid, that's _because_ the engine was null, so we should definitely not call a function on the engine.) Task-number: QTBUG-14842 Reviewed-by: Jedrzej Nowacki
Diffstat (limited to 'tests/auto/qscriptengine')
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 7133a6c..3a376ec 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -120,6 +120,7 @@ private slots:
void uncaughtException();
void errorMessage_QT679();
void valueConversion();
+ void qScriptValueFromValue_noEngine();
void importExtension();
void infiniteRecursion();
void castWithPrototypeChain();
@@ -2258,6 +2259,12 @@ void tst_QScriptEngine::valueConversion()
}
}
+void tst_QScriptEngine::qScriptValueFromValue_noEngine()
+{
+ QVERIFY(!qScriptValueFromValue(0, 123).isValid());
+ QVERIFY(!qScriptValueFromValue(0, QVariant(123)).isValid());
+}
+
static QScriptValue __import__(QScriptContext *ctx, QScriptEngine *eng)
{
return eng->importExtension(ctx->argument(0).toString());