From 4f1ed0948b99af617fa978f0f1b72e48a9fe774f Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 21 Oct 2013 14:43:19 +0200 Subject: Avoid crash when a QML signal is connected to a non-void slot Don't pass a QVariant pointer for the return value when we're not interested in it and the return type might not even be a QVariant (that would be only true for QML methods). Task-number: QTBUG-32801 Change-Id: I8f14e40d8f94caef7e3d086b776735f0484dbf0e Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 3bca862bb7..1fd47c7c66 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1436,14 +1436,15 @@ void *CallArgument::dataPtr() { if (type == -1) return qvariantPtr->data(); - else + else if (type != 0) return (void *)&allocData; + return 0; } void CallArgument::initAsType(int callType) { if (type != 0) { cleanup(); type = 0; } - if (callType == QMetaType::UnknownType) return; + if (callType == QMetaType::UnknownType || callType == QMetaType::Void) return; if (callType == qMetaTypeId()) { qjsValuePtr = new (&allocData) QJSValue(); @@ -1478,9 +1479,6 @@ void CallArgument::initAsType(int callType) } else if (callType == QMetaType::QJsonValue) { type = callType; jsonValuePtr = new (&allocData) QJsonValue(); - } else if (callType == QMetaType::Void) { - type = -1; - qvariantPtr = new (&allocData) QVariant(); } else { type = -1; qvariantPtr = new (&allocData) QVariant(callType, (void *)0); -- cgit v1.2.3