diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2018-03-23 09:28:25 +0100 |
---|---|---|
committer | Jannis Völker <jannis.voelker@basyskom.com> | 2018-04-03 10:42:31 +0000 |
commit | 83710dfb6d6c75073201885dd006b9887514c21e (patch) | |
tree | c02a61851b68013505f8403a4736ce991fc398c4 | |
parent | 1d4ac1cf4e2a55f96a09f30b0bbedbc48a737f9a (diff) |
Fix possible crash in the open62541 backend
QOpen62541Node::enableMonitoring() passes the node id member of the
node to the backend. If a string node id is used and the node is
deleted while or before enableMonitoring in the backend is running,
a crash occurs.
Passing a copy of the node id to the backend fixes the issue.
Change-Id: I0fca4150226c24182022afb95a72dab98f3d712a
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
-rw-r--r-- | src/plugins/opcua/open62541/qopen62541backend.cpp | 2 | ||||
-rw-r--r-- | src/plugins/opcua/open62541/qopen62541node.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/plugins/opcua/open62541/qopen62541backend.cpp b/src/plugins/opcua/open62541/qopen62541backend.cpp index 29fe8d6..24aedf8 100644 --- a/src/plugins/opcua/open62541/qopen62541backend.cpp +++ b/src/plugins/opcua/open62541/qopen62541backend.cpp @@ -238,6 +238,8 @@ void Open62541AsyncBackend::enableMonitoring(uintptr_t handle, UA_NodeId id, QOp } }); + UA_NodeId_deleteMembers(&id); + if (usedSubscription->monitoredItemsCount() == 0) removeSubscription(usedSubscription->subscriptionId()); // No items were added diff --git a/src/plugins/opcua/open62541/qopen62541node.cpp b/src/plugins/opcua/open62541/qopen62541node.cpp index 2b9166b..9285eba 100644 --- a/src/plugins/opcua/open62541/qopen62541node.cpp +++ b/src/plugins/opcua/open62541/qopen62541node.cpp @@ -76,10 +76,12 @@ bool QOpen62541Node::readAttributes(QOpcUa::NodeAttributes attr, const QString & bool QOpen62541Node::enableMonitoring(QOpcUa::NodeAttributes attr, const QOpcUaMonitoringParameters &settings) { + UA_NodeId tempId; + UA_NodeId_copy(&m_nodeId, &tempId); return QMetaObject::invokeMethod(m_client->m_backend, "enableMonitoring", Qt::QueuedConnection, Q_ARG(uintptr_t, reinterpret_cast<uintptr_t>(this)), - Q_ARG(UA_NodeId, m_nodeId), + Q_ARG(UA_NodeId, tempId), Q_ARG(QOpcUa::NodeAttributes, attr), Q_ARG(QOpcUaMonitoringParameters, settings)); } |