summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-10-29 15:03:38 +0200
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 12:24:43 +0200
commiteb65a8de45b3813d154b6ba00de0de025dadc7d8 (patch)
tree640247c2093662df9fe335cd50843d28fb0b06be /tests
parentd6ddf6e8c2ae9629c0b8d99e5215a91cd183cfe1 (diff)
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')
-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 5028b47ede..00cd4a4d1d 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();
@@ -2230,6 +2231,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());