summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-10-29 13:03:38 (GMT)
committerQt Commercial Integration <QtCommercial@digia.com>2012-01-31 10:24:43 (GMT)
commiteb65a8de45b3813d154b6ba00de0de025dadc7d8 (patch)
tree640247c2093662df9fe335cd50843d28fb0b06be /src
parentd6ddf6e8c2ae9629c0b8d99e5215a91cd183cfe1 (diff)
downloadQt-eb65a8de45b3813d154b6ba00de0de025dadc7d8.zip
Qt-eb65a8de45b3813d154b6ba00de0de025dadc7d8.tar.gz
Qt-eb65a8de45b3813d154b6ba00de0de025dadc7d8.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 'src')
-rw-r--r--src/script/api/qscriptengine.h5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h
index c1b353a..caafd57 100644
--- a/src/script/api/qscriptengine.h
+++ b/src/script/api/qscriptengine.h
@@ -337,10 +337,7 @@ inline QScriptValue qScriptValueFromValue(QScriptEngine *engine, const T &t)
template <>
inline QScriptValue qScriptValueFromValue<QVariant>(QScriptEngine *engine, const QVariant &v)
{
- QScriptValue result = qScriptValueFromValue_helper(engine, v.userType(), v.data());
- if (!result.isValid())
- result = engine->newVariant(v);
- return result;
+ return qScriptValueFromValue_helper(engine, v.userType(), v.data());
}
inline bool qscriptvalue_cast_helper(const QScriptValue &value, int type, void *ptr)